@babelx/cli 0.2.0 → 0.2.1

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/bx +28 -24
  2. package/package.json +1 -1
package/bin/bx CHANGED
@@ -4,24 +4,28 @@
4
4
  * Detects platform and runs the appropriate binary
5
5
  */
6
6
 
7
- const { spawn } = require('child_process');
8
- const path = require('path');
9
- const fs = require('fs');
10
- const os = require('os');
7
+ import { spawn } from "node:child_process";
8
+ import { existsSync } from "node:fs";
9
+ import { join, dirname } from "node:path";
10
+ import { fileURLToPath } from "node:url";
11
+ import { platform as getPlatformName, arch as getArch } from "node:os";
12
+
13
+ const __filename = fileURLToPath(import.meta.url);
14
+ const __dirname = dirname(__filename);
11
15
 
12
16
  function getPlatform() {
13
- const platform = os.platform();
14
- const arch = os.arch();
17
+ const platform = getPlatformName();
18
+ const arch = getArch();
15
19
 
16
20
  const platformMap = {
17
- 'darwin': 'darwin',
18
- 'linux': 'linux',
19
- 'win32': 'windows'
21
+ darwin: "darwin",
22
+ linux: "linux",
23
+ win32: "windows",
20
24
  };
21
25
 
22
26
  const archMap = {
23
- 'x64': 'x64',
24
- 'arm64': 'arm64'
27
+ x64: "x64",
28
+ arm64: "arm64",
25
29
  };
26
30
 
27
31
  const p = platformMap[platform];
@@ -37,9 +41,9 @@ function getPlatform() {
37
41
 
38
42
  function getBinaryPath() {
39
43
  const platform = getPlatform();
40
- const binDir = path.join(__dirname, '..', 'vendor');
41
- const binName = platform.startsWith('windows') ? 'bx.exe' : 'bx';
42
- const binPath = path.join(binDir, platform, binName);
44
+ const binDir = join(__dirname, "..", "vendor");
45
+ const binName = platform.startsWith("windows") ? "bx.exe" : "bx";
46
+ const binPath = join(binDir, platform, binName);
43
47
 
44
48
  return binPath;
45
49
  }
@@ -48,27 +52,27 @@ function main() {
48
52
  const binaryPath = getBinaryPath();
49
53
 
50
54
  // Check if binary exists
51
- if (!fs.existsSync(binaryPath)) {
52
- console.error('BabelX CLI binary not found.');
55
+ if (!existsSync(binaryPath)) {
56
+ console.error("BabelX CLI binary not found.");
53
57
  console.error(`Expected path: ${binaryPath}`);
54
- console.error('');
55
- console.error('Please run: npm install @babelx/cli');
56
- console.error('Or download the binary manually from GitHub releases.');
58
+ console.error("");
59
+ console.error("Please run: npm install @babelx/cli");
60
+ console.error("Or download the binary manually from GitHub releases.");
57
61
  process.exit(1);
58
62
  }
59
63
 
60
64
  // Run the binary with all arguments
61
65
  const child = spawn(binaryPath, process.argv.slice(2), {
62
- stdio: 'inherit',
63
- windowsHide: true
66
+ stdio: "inherit",
67
+ windowsHide: true,
64
68
  });
65
69
 
66
- child.on('error', (err) => {
67
- console.error('Failed to start BabelX CLI:', err.message);
70
+ child.on("error", (err) => {
71
+ console.error("Failed to start BabelX CLI:", err.message);
68
72
  process.exit(1);
69
73
  });
70
74
 
71
- child.on('exit', (code) => {
75
+ child.on("exit", (code) => {
72
76
  process.exit(code || 0);
73
77
  });
74
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babelx/cli",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "BabelX CLI - AI-powered translation and i18n management tool",
5
5
  "module": "index.ts",
6
6
  "type": "module",