@knighted/duel 3.2.4 → 3.2.5

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/dist/cjs/duel.cjs CHANGED
@@ -36,7 +36,8 @@ const getSubpath = (mode, relFromRoot) => {
36
36
  return null;
37
37
  };
38
38
  const handleErrorAndExit = message => {
39
- const exitCode = Number(message);
39
+ const parsed = parseInt(message, 10);
40
+ const exitCode = Number.isNaN(parsed) ? 1 : parsed;
40
41
  (0, util_js_1.logError)('Compilation errors found.');
41
42
  process.exit(exitCode);
42
43
  };
@@ -201,10 +202,10 @@ const duel = async (args) => {
201
202
  if (ctx) {
202
203
  const { projectDir, tsconfig, configPath, modules, dirs, transformSyntax, pkg, exports: exportsOpt, } = ctx;
203
204
  const tsc = await (0, find_up_1.findUp)(async (dir) => {
204
- const tscBin = (0, node_path_1.join)(dir, 'node_modules', '.bin', 'tsc');
205
+ const candidate = (0, node_path_1.join)(dir, 'node_modules', 'typescript', 'bin', 'tsc');
205
206
  try {
206
- await (0, promises_1.access)(tscBin);
207
- return tscBin;
207
+ await (0, promises_1.access)(candidate);
208
+ return (0, node_path_1.resolve)(candidate);
208
209
  }
209
210
  catch {
210
211
  /* continue */
@@ -212,8 +213,10 @@ const duel = async (args) => {
212
213
  }, { cwd: projectDir });
213
214
  const runBuild = (project, outDir) => {
214
215
  return new Promise((resolve, reject) => {
215
- const args = outDir ? ['-p', project, '--outDir', outDir] : ['-p', project];
216
- const build = (0, node_child_process_1.spawn)(tsc, args, { stdio: 'inherit', shell: node_process_1.platform === 'win32' });
216
+ const args = outDir
217
+ ? [tsc, '-p', project, '--outDir', outDir]
218
+ : [tsc, '-p', project];
219
+ const build = (0, node_child_process_1.spawn)(process.execPath, args, { stdio: 'inherit' });
217
220
  build.on('exit', code => {
218
221
  if (code > 0) {
219
222
  return reject(new Error(code));
package/dist/cjs/util.cjs CHANGED
@@ -45,10 +45,9 @@ const getRealPathAsFileUrl = async (path) => {
45
45
  return asFileUrl;
46
46
  };
47
47
  exports.getRealPathAsFileUrl = getRealPathAsFileUrl;
48
- const getCompileFiles = (tscBinPath, wd = (0, node_process_1.cwd)()) => {
49
- const { stdout } = (0, node_child_process_1.spawnSync)(tscBinPath, ['--listFilesOnly'], {
48
+ const getCompileFiles = (tscPath, wd = (0, node_process_1.cwd)()) => {
49
+ const { stdout } = (0, node_child_process_1.spawnSync)(process.execPath, [tscPath, '--listFilesOnly'], {
50
50
  cwd: wd,
51
- shell: node_process_1.platform === 'win32',
52
51
  });
53
52
  // Exclude node_modules and empty strings.
54
53
  return stdout
@@ -3,4 +3,4 @@ export function logError(msg: any): void;
3
3
  export function logSuccess(msg: any): void;
4
4
  export function logWarn(msg: any): void;
5
5
  export function getRealPathAsFileUrl(path: any): Promise<string>;
6
- export function getCompileFiles(tscBinPath: any, wd?: string): string[];
6
+ export function getCompileFiles(tscPath: any, wd?: string): string[];
package/dist/esm/duel.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { argv, platform } from 'node:process';
2
+ import { argv } from 'node:process';
3
3
  import { join, dirname, resolve, relative, parse as parsePath, posix } from 'node:path';
4
4
  import { spawn } from 'node:child_process';
5
5
  import { writeFile, rm, rename, mkdir, cp, access, readFile } from 'node:fs/promises';
@@ -33,7 +33,8 @@ const getSubpath = (mode, relFromRoot) => {
33
33
  return null;
34
34
  };
35
35
  const handleErrorAndExit = message => {
36
- const exitCode = Number(message);
36
+ const parsed = parseInt(message, 10);
37
+ const exitCode = Number.isNaN(parsed) ? 1 : parsed;
37
38
  logError('Compilation errors found.');
38
39
  process.exit(exitCode);
39
40
  };
@@ -198,10 +199,10 @@ const duel = async (args) => {
198
199
  if (ctx) {
199
200
  const { projectDir, tsconfig, configPath, modules, dirs, transformSyntax, pkg, exports: exportsOpt, } = ctx;
200
201
  const tsc = await findUp(async (dir) => {
201
- const tscBin = join(dir, 'node_modules', '.bin', 'tsc');
202
+ const candidate = join(dir, 'node_modules', 'typescript', 'bin', 'tsc');
202
203
  try {
203
- await access(tscBin);
204
- return tscBin;
204
+ await access(candidate);
205
+ return resolve(candidate);
205
206
  }
206
207
  catch {
207
208
  /* continue */
@@ -209,8 +210,10 @@ const duel = async (args) => {
209
210
  }, { cwd: projectDir });
210
211
  const runBuild = (project, outDir) => {
211
212
  return new Promise((resolve, reject) => {
212
- const args = outDir ? ['-p', project, '--outDir', outDir] : ['-p', project];
213
- const build = spawn(tsc, args, { stdio: 'inherit', shell: platform === 'win32' });
213
+ const args = outDir
214
+ ? [tsc, '-p', project, '--outDir', outDir]
215
+ : [tsc, '-p', project];
216
+ const build = spawn(process.execPath, args, { stdio: 'inherit' });
214
217
  build.on('exit', code => {
215
218
  if (code > 0) {
216
219
  return reject(new Error(code));
@@ -3,4 +3,4 @@ export function logError(msg: any): void;
3
3
  export function logSuccess(msg: any): void;
4
4
  export function logWarn(msg: any): void;
5
5
  export function getRealPathAsFileUrl(path: any): Promise<string>;
6
- export function getCompileFiles(tscBinPath: any, wd?: string): string[];
6
+ export function getCompileFiles(tscPath: any, wd?: string): string[];
package/dist/esm/util.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { pathToFileURL } from 'node:url';
2
2
  import { realpath } from 'node:fs/promises';
3
3
  import { spawnSync } from 'node:child_process';
4
- import { cwd, platform } from 'node:process';
4
+ import { cwd } from 'node:process';
5
5
  import { EOL } from 'node:os';
6
6
  const COLORS = {
7
7
  reset: '\x1b[0m',
@@ -37,10 +37,9 @@ const getRealPathAsFileUrl = async (path) => {
37
37
  const asFileUrl = pathToFileURL(realPath).href;
38
38
  return asFileUrl;
39
39
  };
40
- const getCompileFiles = (tscBinPath, wd = cwd()) => {
41
- const { stdout } = spawnSync(tscBinPath, ['--listFilesOnly'], {
40
+ const getCompileFiles = (tscPath, wd = cwd()) => {
41
+ const { stdout } = spawnSync(process.execPath, [tscPath, '--listFilesOnly'], {
42
42
  cwd: wd,
43
- shell: platform === 'win32',
44
43
  });
45
44
  // Exclude node_modules and empty strings.
46
45
  return stdout
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knighted/duel",
3
- "version": "3.2.4",
3
+ "version": "3.2.5",
4
4
  "description": "TypeScript dual packages.",
5
5
  "type": "module",
6
6
  "main": "dist/esm/duel.js",
@@ -25,7 +25,7 @@
25
25
  "lint": "eslint src/*.js test/*.js",
26
26
  "test:integration": "node --test --test-reporter=spec test/integration.js",
27
27
  "test:monorepos": "node --test --test-reporter=spec test/monorepos.js",
28
- "test": "c8 --reporter=text --reporter=text-summary --reporter=lcov node --test --test-reporter=spec test/integration.js test/monorepos.js",
28
+ "test": "c8 --reporter=text --reporter=text-summary --reporter=lcov node --trace-deprecation --test --test-reporter=spec test/integration.js test/monorepos.js",
29
29
  "build": "node src/duel.js --dirs --mode globals",
30
30
  "prepack": "npm run build",
31
31
  "prepare": "husky"
@@ -70,6 +70,7 @@
70
70
  "@tsconfig/recommended": "^1.0.10",
71
71
  "@types/node": "^24.10.1",
72
72
  "c8": "^10.1.3",
73
+ "cross-spawn": "^7.0.6",
73
74
  "eslint": "^9.39.1",
74
75
  "eslint-plugin-n": "^17.23.1",
75
76
  "globals": "^16.3.0",