create-merlin-brain 3.0.2 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/install.cjs +9 -3
- package/package.json +1 -1
package/bin/install.cjs
CHANGED
|
@@ -617,17 +617,23 @@ function cleanupLegacy() {
|
|
|
617
617
|
|
|
618
618
|
// ═══════════════════════════════════════════════════════════════
|
|
619
619
|
// CLEAN NPX CACHE (remove old cached versions of merlin packages)
|
|
620
|
+
// Skip the directory we're currently running from (when invoked via npx)
|
|
620
621
|
// ═══════════════════════════════════════════════════════════════
|
|
621
622
|
try {
|
|
622
623
|
const npxCacheDir = path.join(os.homedir(), '.npm', '_npx');
|
|
623
624
|
if (fs.existsSync(npxCacheDir)) {
|
|
625
|
+
// Resolve which npx cache dir we're running from (if any) so we don't delete ourselves
|
|
626
|
+
const ownDir = path.resolve(__dirname, '..');
|
|
624
627
|
const entries = fs.readdirSync(npxCacheDir, { withFileTypes: true });
|
|
625
628
|
for (const entry of entries) {
|
|
626
629
|
if (!entry.isDirectory()) continue;
|
|
627
|
-
const
|
|
628
|
-
|
|
630
|
+
const entryPath = path.join(npxCacheDir, entry.name);
|
|
631
|
+
// Never delete the directory we're currently executing from
|
|
632
|
+
if (ownDir.startsWith(entryPath)) continue;
|
|
633
|
+
const pkgJsonPath = path.join(entryPath, 'node_modules', 'create-merlin-brain', 'package.json');
|
|
634
|
+
const pkgJsonPath2 = path.join(entryPath, 'node_modules', 'create-merlin-pro', 'package.json');
|
|
629
635
|
if (fs.existsSync(pkgJsonPath) || fs.existsSync(pkgJsonPath2)) {
|
|
630
|
-
removeDirRecursive(
|
|
636
|
+
removeDirRecursive(entryPath);
|
|
631
637
|
cleaned.push('~/.npm/_npx/' + entry.name + ' (old npx cache)');
|
|
632
638
|
}
|
|
633
639
|
}
|
package/package.json
CHANGED