offwatch 0.5.4 → 0.5.6
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/offwatch.js +10 -3
- package/lib/downloader.js +4 -4
- package/package.json +1 -1
package/bin/offwatch.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { loadCLIBinPath } from "
|
|
3
|
-
import { execSync } from "child_process";
|
|
2
|
+
import { loadCLIBinPath } from "../lib/downloader.js";
|
|
3
|
+
import { execSync, spawn } from "child_process";
|
|
4
4
|
import { dirname } from "path";
|
|
5
5
|
import { fileURLToPath } from "url";
|
|
6
6
|
|
|
7
7
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
8
|
|
|
9
9
|
const binPath = await loadCLIBinPath(__dirname);
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
// On Windows, run with node. On Unix, run directly
|
|
12
|
+
const isWindows = process.platform === "win32";
|
|
13
|
+
if (isWindows) {
|
|
14
|
+
spawn("node", [binPath], { stdio: "inherit" });
|
|
15
|
+
} else {
|
|
16
|
+
execSync(binPath, { stdio: "inherit" });
|
|
17
|
+
}
|
package/lib/downloader.js
CHANGED
|
@@ -71,10 +71,11 @@ const downloadRelease = async (versionDir) => {
|
|
|
71
71
|
const filePath = path.join(versionDir, CLI_FILENAME);
|
|
72
72
|
logDebug(`download(${asset.browser_download_url})`);
|
|
73
73
|
|
|
74
|
-
// For .js files,
|
|
74
|
+
// For .js files, download to temp then rename
|
|
75
75
|
if (asset.name.endsWith(".js")) {
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
const tempPath = path.join(versionDir, asset.name);
|
|
77
|
+
await pipeline(got.stream(asset.browser_download_url), fs.createWriteStream(tempPath));
|
|
78
|
+
fs.renameSync(tempPath, filePath);
|
|
78
79
|
} else {
|
|
79
80
|
// For compressed files
|
|
80
81
|
const tarPath = path.join(versionDir, path.basename(asset.browser_download_url));
|
|
@@ -89,7 +90,6 @@ const decompress = async (tarPath, outPath) => {
|
|
|
89
90
|
C: path.dirname(outPath),
|
|
90
91
|
strip: 1,
|
|
91
92
|
}));
|
|
92
|
-
fs.chmodSync(outPath, 0o755);
|
|
93
93
|
};
|
|
94
94
|
|
|
95
95
|
export const loadCLIBinPath = async (cwd) => {
|