stacktape 3.0.10-beta.0 → 3.0.10-beta.2
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/stacktape.js +33 -11
- package/package.json +1 -1
package/bin/stacktape.js
CHANGED
|
@@ -6,7 +6,16 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
const { spawnSync, execSync } = require('node:child_process');
|
|
9
|
-
const {
|
|
9
|
+
const {
|
|
10
|
+
createWriteStream,
|
|
11
|
+
existsSync,
|
|
12
|
+
chmodSync,
|
|
13
|
+
mkdirSync,
|
|
14
|
+
accessSync,
|
|
15
|
+
constants,
|
|
16
|
+
unlinkSync,
|
|
17
|
+
readFileSync
|
|
18
|
+
} = require('node:fs');
|
|
10
19
|
const { get: httpsGet } = require('node:https');
|
|
11
20
|
const { platform, arch, homedir } = require('node:os');
|
|
12
21
|
const { join } = require('node:path');
|
|
@@ -230,25 +239,38 @@ function getManualInstallCommand(platformKey) {
|
|
|
230
239
|
return commands[platformKey] || 'See https://docs.stacktape.com for installation instructions';
|
|
231
240
|
}
|
|
232
241
|
|
|
233
|
-
function
|
|
242
|
+
function getGlobalBinaryPathIfVersionMatches() {
|
|
234
243
|
const binaryName = platform() === 'win32' ? 'stacktape.exe' : 'stacktape';
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
244
|
+
const globalDir = join(homedir(), '.stacktape', 'bin');
|
|
245
|
+
const globalBinaryPath = join(globalDir, binaryName);
|
|
246
|
+
const releaseDataPath = join(globalDir, 'release-data.json');
|
|
247
|
+
|
|
248
|
+
if (!existsSync(globalBinaryPath) || !existsSync(releaseDataPath)) {
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
try {
|
|
253
|
+
const { version } = JSON.parse(readFileSync(releaseDataPath, 'utf8'));
|
|
254
|
+
if (version !== PACKAGE_VERSION) {
|
|
255
|
+
return null;
|
|
242
256
|
}
|
|
257
|
+
} catch {
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
try {
|
|
262
|
+
accessSync(globalBinaryPath, constants.X_OK);
|
|
263
|
+
return globalBinaryPath;
|
|
264
|
+
} catch {
|
|
265
|
+
return globalBinaryPath;
|
|
243
266
|
}
|
|
244
|
-
return null;
|
|
245
267
|
}
|
|
246
268
|
|
|
247
269
|
async function main() {
|
|
248
270
|
try {
|
|
249
271
|
const args = process.argv.slice(2);
|
|
250
272
|
|
|
251
|
-
const globalBinaryPath =
|
|
273
|
+
const globalBinaryPath = getGlobalBinaryPathIfVersionMatches();
|
|
252
274
|
if (globalBinaryPath) {
|
|
253
275
|
const result = spawnSync(globalBinaryPath, args, {
|
|
254
276
|
stdio: 'inherit',
|