@loukotal/devmoji-rs 0.1.3

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.
Files changed (2) hide show
  1. package/bin/cli.js +63 -0
  2. package/package.json +24 -0
package/bin/cli.js ADDED
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { execFileSync } = require("child_process");
4
+ const path = require("path");
5
+
6
+ const PLATFORMS = {
7
+ "darwin-arm64": "@loukotal/devmoji-rs-darwin-arm64",
8
+ "darwin-x64": "@loukotal/devmoji-rs-darwin-x64",
9
+ "linux-x64-gnu": "@loukotal/devmoji-rs-linux-x64-gnu",
10
+ "linux-x64-musl": "@loukotal/devmoji-rs-linux-x64-musl",
11
+ "linux-arm64-gnu": "@loukotal/devmoji-rs-linux-arm64-gnu",
12
+ "win32-x64": "@loukotal/devmoji-rs-win32-x64",
13
+ };
14
+
15
+ function getBinaryPath() {
16
+ const platform = process.platform;
17
+ const arch = process.arch;
18
+ const binaryName = platform === "win32" ? "devmoji.exe" : "devmoji";
19
+
20
+ if (platform === "linux") {
21
+ const candidates = [`${platform}-${arch}-musl`, `${platform}-${arch}-gnu`];
22
+ for (const candidate of candidates) {
23
+ const pkg = PLATFORMS[candidate];
24
+ if (pkg) {
25
+ try {
26
+ return path.join(
27
+ path.dirname(require.resolve(`${pkg}/package.json`)),
28
+ "bin",
29
+ binaryName
30
+ );
31
+ } catch {}
32
+ }
33
+ }
34
+ } else {
35
+ const key = `${platform}-${arch}`;
36
+ const pkg = PLATFORMS[key];
37
+ if (pkg) {
38
+ try {
39
+ return path.join(
40
+ path.dirname(require.resolve(`${pkg}/package.json`)),
41
+ "bin",
42
+ binaryName
43
+ );
44
+ } catch {}
45
+ }
46
+ }
47
+
48
+ throw new Error(
49
+ `Unsupported platform: ${platform}-${arch}. ` +
50
+ `devmoji-rs does not have a prebuilt binary for your system.`
51
+ );
52
+ }
53
+
54
+ try {
55
+ const binary = getBinaryPath();
56
+ execFileSync(binary, process.argv.slice(2), { stdio: "inherit" });
57
+ } catch (err) {
58
+ if (err.status !== undefined) {
59
+ process.exit(err.status);
60
+ }
61
+ console.error(err.message);
62
+ process.exit(1);
63
+ }
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@loukotal/devmoji-rs",
3
+ "version": "0.1.3",
4
+ "description": "CLI tool to add emoji to conventional commits",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/loukotal/devmoji-rs"
9
+ },
10
+ "bin": {
11
+ "devmoji-rs": "bin/cli.js"
12
+ },
13
+ "files": [
14
+ "bin/"
15
+ ],
16
+ "optionalDependencies": {
17
+ "@loukotal/devmoji-rs-darwin-arm64": "0.1.3",
18
+ "@loukotal/devmoji-rs-darwin-x64": "0.1.3",
19
+ "@loukotal/devmoji-rs-linux-x64-gnu": "0.1.3",
20
+ "@loukotal/devmoji-rs-linux-x64-musl": "0.1.3",
21
+ "@loukotal/devmoji-rs-linux-arm64-gnu": "0.1.3",
22
+ "@loukotal/devmoji-rs-win32-x64": "0.1.3"
23
+ }
24
+ }