Skip to content

Commit 3566d40

Browse files
committed
Upgrade args-tokenizer
1 parent 3641f1d commit 3566d40

File tree

6 files changed

+17
-14
lines changed

6 files changed

+17
-14
lines changed

lib/node-arguments.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ import {tokenizeArgs} from 'args-tokenizer';
55
export default function normalizeNodeArguments(fromConf = [], fromArgv = '') {
66
let parsedArgv = [];
77
if (fromArgv !== '') {
8-
parsedArgv = tokenizeArgs(fromArgv);
8+
try {
9+
parsedArgv = tokenizeArgs(fromArgv);
10+
} catch {
11+
throw new Error('Could not parse `--node-arguments` value. Make sure all strings are closed and backslashes are used correctly.');
12+
}
913
}
1014

1115
return [...process.execArgv, ...fromConf, ...parsedArgv];

package-lock.json

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
"acorn": "^8.13.0",
8888
"acorn-walk": "^8.3.4",
8989
"ansi-styles": "^6.2.1",
90-
"args-tokenizer": "^0.2.1",
90+
"args-tokenizer": "^0.3.0",
9191
"arrify": "^3.0.0",
9292
"callsites": "^4.2.0",
9393
"cbor": "^9.0.2",
@@ -151,6 +151,5 @@
151151
},
152152
"volta": {
153153
"node": "22.10.0"
154-
},
155-
"packageManager": "[email protected]+sha512.76e2379760a4328ec4415815bcd6628dee727af3779aaa4c914e3944156c4299921a89f976381ee107d41f12cfa4b66681ca9c718f0668fa0831ed4c6d8ba56c"
154+
}
156155
}

test/node-arguments/snapshots/test.js.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ Generated by [AVA](https://avajs.dev).
3737
},
3838
]
3939

40-
## forgive incomplete --node-arguments
40+
## detects incomplete --node-arguments
4141

42-
> tests pass
42+
> fails with message
4343
44-
[]
44+
'Could not parse `--node-arguments` value. Make sure all strings are closed and backslashes are used correctly.'
4545

4646
## reads node arguments from config
4747

-17 Bytes
Binary file not shown.

test/node-arguments/test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import test from '@ava/test';
22

3-
import {cwd, fixture} from '../helpers/exec.js';
3+
import {cleanOutput, cwd, fixture} from '../helpers/exec.js';
44

55
test('passed node arguments to workers', async t => {
66
const options = {
@@ -33,14 +33,14 @@ test('`filterNodeArgumentsForWorkerThreads` configuration ignored for worker pro
3333
t.snapshot(result.stats.passed, 'tests pass');
3434
});
3535

36-
test('forgive incomplete --node-arguments', async t => {
36+
test('detects incomplete --node-arguments', async t => {
3737
const options = {
3838
cwd: cwd('node-arguments'),
3939
};
4040

4141
const result = await t.throwsAsync(fixture(['--node-arguments="--foo=\'bar"', 'node-arguments.js'], options));
4242

43-
t.snapshot(result.stats.passed, 'tests pass');
43+
t.snapshot(cleanOutput(result.stderr), 'fails with message');
4444
});
4545

4646
test('reads node arguments from config', async t => {

0 commit comments

Comments
 (0)