betool-cli 0.6.2 → 0.6.4
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/install.js +14 -32
- package/package.json +1 -1
package/install.js
CHANGED
|
@@ -79,50 +79,32 @@ function download(url, dest) {
|
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
// cleanupResiduals
|
|
83
|
-
//
|
|
84
|
-
//
|
|
85
|
-
//
|
|
86
|
-
//
|
|
82
|
+
// cleanupResiduals tidies ONLY this package's own bin/ dir : it drops a stale
|
|
83
|
+
// betool binary for the *wrong platform* or a partial previous download, so the
|
|
84
|
+
// freshly downloaded one is the only executable present. The ``betool.js``
|
|
85
|
+
// launcher is kept.
|
|
86
|
+
//
|
|
87
|
+
// It deliberately does NOT touch %LOCALAPPDATA%\betool\bin : that is a
|
|
88
|
+
// first-class install location managed by ``betool install`` (it is added to
|
|
89
|
+
// the user's PATH and hosts the IntelliJ plugin), NOT a residual. Deleting it
|
|
90
|
+
// from here would break users who installed via ``betool install``.
|
|
91
|
+
//
|
|
92
|
+
// Best-effort : every step is guarded, a failure here never fails the install.
|
|
87
93
|
function cleanupResiduals(activeDest) {
|
|
88
94
|
const removed = [];
|
|
89
|
-
|
|
90
|
-
// 1. Our own bin/ dir : drop any betool binary that isn't the active one
|
|
91
|
-
// (e.g. a wrong-platform leftover or a partial previous download). The
|
|
92
|
-
// ``betool.js`` launcher is kept.
|
|
93
95
|
try {
|
|
94
96
|
const binDir = path.dirname(activeDest);
|
|
95
97
|
for (const f of fs.readdirSync(binDir)) {
|
|
96
98
|
const full = path.join(binDir, f);
|
|
97
99
|
if (full === activeDest || f === "betool.js") continue;
|
|
98
|
-
if (/^betool(\.exe)?$/.test(f)
|
|
99
|
-
try { fs.rmSync(full, { force: true }); removed.push(
|
|
100
|
+
if (/^betool(\.exe)?$/.test(f)) {
|
|
101
|
+
try { fs.rmSync(full, { force: true }); removed.push(f); } catch (_) {}
|
|
100
102
|
}
|
|
101
103
|
}
|
|
102
104
|
} catch (_) {}
|
|
103
105
|
|
|
104
|
-
// 2. Legacy standalone install location (Makefile ``install-client`` and
|
|
105
|
-
// manual copies dropped a binary in %LOCALAPPDATA%\betool\bin). Remove it
|
|
106
|
-
// so the npm install is the single source of truth.
|
|
107
|
-
const legacyDirs = [];
|
|
108
|
-
if (process.platform === "win32" && process.env.LOCALAPPDATA) {
|
|
109
|
-
legacyDirs.push(path.join(process.env.LOCALAPPDATA, "betool", "bin"));
|
|
110
|
-
}
|
|
111
|
-
const ext = process.platform === "win32" ? ".exe" : "";
|
|
112
|
-
for (const dir of legacyDirs) {
|
|
113
|
-
const legacyBin = path.join(dir, `betool${ext}`);
|
|
114
|
-
try {
|
|
115
|
-
if (fs.existsSync(legacyBin) && path.resolve(legacyBin) !== path.resolve(activeDest)) {
|
|
116
|
-
fs.rmSync(legacyBin, { force: true });
|
|
117
|
-
removed.push(legacyBin);
|
|
118
|
-
try { if (fs.readdirSync(dir).length === 0) fs.rmdirSync(dir); } catch (_) {}
|
|
119
|
-
}
|
|
120
|
-
} catch (_) {}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
106
|
if (removed.length) {
|
|
124
|
-
console.log(` nettoyage : ${removed.
|
|
125
|
-
for (const r of removed) console.log(` - ${r}`);
|
|
107
|
+
console.log(` nettoyage : ${removed.join(", ")}`);
|
|
126
108
|
}
|
|
127
109
|
}
|
|
128
110
|
|