audio-trim-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/win32-x64/audio-trim.exe +0 -0
- package/index.js +37 -0
- package/package.json +15 -0
|
Binary file
|
package/index.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { spawnSync } = require("child_process");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
|
|
6
|
+
const platform = process.platform; // win32, darwin, linux
|
|
7
|
+
const arch = process.arch; // x64, arm64
|
|
8
|
+
|
|
9
|
+
function die(msg) {
|
|
10
|
+
console.error(`[audio-trim] ${msg}`);
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let relPath;
|
|
15
|
+
|
|
16
|
+
if (platform === "win32") {
|
|
17
|
+
if (arch !== "x64") die(`Unsupported arch ${arch} on Windows (x64 only).`);
|
|
18
|
+
relPath = "bin/win32-x64/audio-trim.exe";
|
|
19
|
+
} else if (platform === "darwin") {
|
|
20
|
+
if (arch === "arm64") relPath = "bin/darwin-arm64/audio-trim";
|
|
21
|
+
else if (arch === "x64") relPath = "bin/darwin-x64/audio-trim";
|
|
22
|
+
else die(`Unsupported arch ${arch} on macOS.`);
|
|
23
|
+
} else if (platform === "linux") {
|
|
24
|
+
if (arch === "x64") relPath = "bin/linux-x64/audio-trim";
|
|
25
|
+
else if (arch === "arm64") relPath = "bin/linux-arm64/audio-trim";
|
|
26
|
+
else die(`Unsupported arch ${arch} on Linux.`);
|
|
27
|
+
} else {
|
|
28
|
+
die(`Unsupported platform ${platform}`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const binPath = path.join(__dirname, relPath);
|
|
32
|
+
if (!fs.existsSync(binPath)) {
|
|
33
|
+
die(`Missing binary: ${relPath}`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const res = spawnSync(binPath, process.argv.slice(2), { stdio: "inherit" });
|
|
37
|
+
process.exit(res.status ?? 1);
|
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "audio-trim-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Trim leading and trailing silence from WAV files",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"bin": {
|
|
7
|
+
"audio-trim": "index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"index.js",
|
|
11
|
+
"bin/**"
|
|
12
|
+
],
|
|
13
|
+
"os": ["darwin", "linux", "win32"],
|
|
14
|
+
"cpu": ["x64", "arm64"]
|
|
15
|
+
}
|