@sortlist/cli 0.35.0 → 0.37.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/sl.mjs CHANGED
@@ -52,22 +52,35 @@ if (process.env.SL_PREFER_LOCAL !== '0') {
52
52
  }
53
53
  }
54
54
 
55
- const tsxPath = resolve(selfRoot, 'node_modules/.bin/tsx');
56
- const entryPoint = resolve(selfRoot, 'src/index.ts');
55
+ // Published builds ship a bundled dist/; source checkouts run TypeScript via
56
+ // tsx — even when a locally-built dist/ exists, so stale bundles never shadow
57
+ // the live source.
58
+ const distEntry = resolve(selfRoot, 'dist/index.js');
59
+ const useDist = existsSync(resolve(selfRoot, '.published')) && existsSync(distEntry);
57
60
 
58
- if (!existsSync(tsxPath)) {
59
- console.error(`sl: missing dependency at ${tsxPath} — run \`npm install\` in ${selfRoot}`);
60
- process.exit(1);
61
+ let command;
62
+ let args;
63
+ if (useDist) {
64
+ command = process.execPath;
65
+ args = [distEntry, ...process.argv.slice(2)];
66
+ } else {
67
+ const tsxPath = resolve(selfRoot, 'node_modules/.bin/tsx');
68
+ if (!existsSync(tsxPath)) {
69
+ console.error(`sl: missing dependency at ${tsxPath} — run \`npm install\` in ${selfRoot}`);
70
+ process.exit(1);
71
+ }
72
+ command = tsxPath;
73
+ args = [resolve(selfRoot, 'src/index.ts'), ...process.argv.slice(2)];
61
74
  }
62
75
 
63
76
  try {
64
- execFileSync(tsxPath, [entryPoint, ...process.argv.slice(2)], {
77
+ execFileSync(command, args, {
65
78
  stdio: 'inherit',
66
79
  env: { ...process.env, NODE_OPTIONS: [process.env.NODE_OPTIONS, '--enable-source-maps'].filter(Boolean).join(' ') },
67
80
  });
68
81
  } catch (err) {
69
82
  if (err.code === 'ENOENT') {
70
- console.error(`sl: failed to spawn tsx (${err.message})`);
83
+ console.error(`sl: failed to spawn ${command} (${err.message})`);
71
84
  }
72
85
  process.exit(err.status ?? 1);
73
86
  }