@wakeclawup/cli 0.1.0
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/wcu.js +34 -0
- package/binaries/.gitkeep +0 -0
- package/binaries/wcu-darwin-arm64 +0 -0
- package/binaries/wcu-darwin-x64 +0 -0
- package/binaries/wcu-linux-arm64 +0 -0
- package/binaries/wcu-linux-x64 +0 -0
- package/binaries/wcu-win32-x64.exe +0 -0
- package/package.json +16 -0
package/bin/wcu.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const { spawn } = require("child_process");
|
|
6
|
+
|
|
7
|
+
const targets = {
|
|
8
|
+
"darwin-arm64": "wcu-darwin-arm64",
|
|
9
|
+
"darwin-x64": "wcu-darwin-x64",
|
|
10
|
+
"linux-x64": "wcu-linux-x64",
|
|
11
|
+
"linux-arm64": "wcu-linux-arm64",
|
|
12
|
+
"win32-x64": "wcu-win32-x64.exe"
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const key = `${process.platform}-${process.arch}`;
|
|
16
|
+
const binaryName = targets[key];
|
|
17
|
+
const binaryPath = process.env.WCU_BINARY || (
|
|
18
|
+
binaryName && path.join(__dirname, "..", "binaries", binaryName)
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
if (!binaryPath || !fs.existsSync(binaryPath)) {
|
|
22
|
+
console.error(`wcu: 当前 npm 包没有平台二进制:${key}`);
|
|
23
|
+
console.error("wcu: 开发时可设置 WCU_BINARY 指向 cargo build --release 生成的可执行文件");
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const child = spawn(binaryPath, process.argv.slice(2), { stdio: "inherit" });
|
|
28
|
+
child.on("error", (error) => {
|
|
29
|
+
console.error(`wcu: ${error.message}`);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
});
|
|
32
|
+
child.on("exit", (code, signal) => {
|
|
33
|
+
process.exit(code ?? (signal ? 1 : 0));
|
|
34
|
+
});
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
ADDED