@flowmetelev/wfkit 1.0.1 → 1.0.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/README.md +2 -0
- package/bin/wfkit.js +24 -13
- package/package.json +1 -1
package/README.md
CHANGED
package/bin/wfkit.js
CHANGED
|
@@ -3,25 +3,36 @@
|
|
|
3
3
|
const { existsSync } = require("fs");
|
|
4
4
|
const { join } = require("path");
|
|
5
5
|
const { spawnSync } = require("child_process");
|
|
6
|
+
const { downloadBinary } = require("../install.js");
|
|
6
7
|
|
|
7
8
|
const platform = process.platform;
|
|
8
9
|
const binaryName = platform === "win32" ? "wfkit.exe" : "wfkit";
|
|
9
10
|
const binaryPath = join(__dirname, binaryName);
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
async function main() {
|
|
13
|
+
if (!existsSync(binaryPath)) {
|
|
14
|
+
console.warn("wfkit binary is missing. Attempting to download it now.");
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
await downloadBinary();
|
|
18
|
+
} catch (error) {
|
|
19
|
+
console.error(
|
|
20
|
+
`Failed to download the wfkit binary on first run: ${error.message}`,
|
|
21
|
+
);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const result = spawnSync(binaryPath, process.argv.slice(2), {
|
|
27
|
+
stdio: "inherit",
|
|
28
|
+
});
|
|
17
29
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
30
|
+
if (result.error) {
|
|
31
|
+
console.error(`Failed to start wfkit: ${result.error.message}`);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
21
34
|
|
|
22
|
-
|
|
23
|
-
console.error(`Failed to start wfkit: ${result.error.message}`);
|
|
24
|
-
process.exit(1);
|
|
35
|
+
process.exit(result.status === null ? 1 : result.status);
|
|
25
36
|
}
|
|
26
37
|
|
|
27
|
-
|
|
38
|
+
main();
|