Skip to content

Commit 5ba99e7

Browse files
committedSep 18, 2023
Add nx binaries resolver (resolves #243)
1 parent d17371b commit 5ba99e7

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed
 

‎src/binaries/resolvers/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export * as dotenv from './dotenv.js';
33
export * as node from './node.js';
44
export * as nodemon from './nodemon.js';
55
export * as npx from './npx.js';
6+
export * as nx from './nx.js';
67
export * as pnpm from './pnpm.js';
78
export * as rollup from './rollup.js';
89
export * as yarn from './yarn.js';

‎src/binaries/resolvers/nx.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import parseArgs from 'minimist';
2+
import { toBinary } from '../util.js';
3+
import type { Resolver } from '../types.js';
4+
5+
export const resolve: Resolver = (binary, args, { fromArgs }) => {
6+
const parsed = parseArgs(args);
7+
const [command] = parsed._;
8+
if (command === 'exec') return [toBinary(binary), ...fromArgs(parsed._.slice(1))];
9+
return [toBinary(binary)];
10+
};

‎tests/util/getReferencesFromScripts.test.ts

+6
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ test('getReferencesFromScripts (cross-env)', () => {
8383
t('NODE_ENV=production cross-env -- program --cache', ['bin:cross-env', 'bin:program']);
8484
});
8585

86+
test('getReferencesFromScripts (nx)', () => {
87+
t('nx run myapp:build:production', ['bin:nx']);
88+
t('nx run-many -t build', ['bin:nx']);
89+
t('nx exec -- esbuild main.ts --outdir=build', ['bin:nx', 'bin:esbuild', ts]);
90+
});
91+
8692
test('getReferencesFromScripts (cross-env/node)', () => {
8793
t('cross-env NODE_ENV=production node -r node_modules/dotenv/config ./script.js', ['bin:cross-env', 'dotenv', js]);
8894
t('cross-env NODE_ENV=production node -r esm script.js', ['bin:cross-env', 'esm', js]);

0 commit comments

Comments
 (0)
Please sign in to comment.