midnightwalletsync 0.1.0 → 0.2.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.
@@ -1,17 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import { spawnSync } from 'child_process';
4
+ import { existsSync } from 'fs';
4
5
  import { dirname, join } from 'path';
5
6
  import { fileURLToPath } from 'url';
6
7
 
7
8
  const __dirname = dirname(fileURLToPath(import.meta.url));
8
9
  const rootDir = join(__dirname, '..');
9
10
 
10
- // Try to find tsx from package node_modules
11
- const tsxPath = join(rootDir, 'node_modules', '.bin', 'tsx');
11
+ // Resolve tsx from package-local node_modules first, then hoisted node_modules.
12
+ const localTsxPath = join(rootDir, 'node_modules', '.bin', 'tsx');
13
+ const hoistedTsxPath = join(rootDir, '..', '.bin', 'tsx');
14
+ const tsxPath = existsSync(localTsxPath) ? localTsxPath : hoistedTsxPath;
12
15
 
13
16
  const result = spawnSync(tsxPath, [join(rootDir, 'src', 'cli.ts'), ...process.argv.slice(2)], {
14
- cwd: rootDir,
17
+ cwd: process.cwd(),
15
18
  env: {
16
19
  ...process.env,
17
20
  NODE_OPTIONS: '--no-deprecation',
@@ -19,4 +22,9 @@ const result = spawnSync(tsxPath, [join(rootDir, 'src', 'cli.ts'), ...process.ar
19
22
  stdio: 'inherit',
20
23
  });
21
24
 
25
+ if (result.error) {
26
+ console.error('[error] failed to start CLI:', result.error.message);
27
+ process.exit(1);
28
+ }
29
+
22
30
  process.exit(result.status ?? 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "midnightwalletsync",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"