Skip to content

Commit

Permalink
Upgrade args-tokenizer
Browse files Browse the repository at this point in the history
  • Loading branch information
TrySound committed Dec 29, 2024
1 parent 3641f1d commit 3566d40
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 14 deletions.
6 changes: 5 additions & 1 deletion lib/node-arguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import {tokenizeArgs} from 'args-tokenizer';
export default function normalizeNodeArguments(fromConf = [], fromArgv = '') {
let parsedArgv = [];
if (fromArgv !== '') {
parsedArgv = tokenizeArgs(fromArgv);
try {
parsedArgv = tokenizeArgs(fromArgv);
} catch {
throw new Error('Could not parse `--node-arguments` value. Make sure all strings are closed and backslashes are used correctly.');
}
}

return [...process.execArgv, ...fromConf, ...parsedArgv];
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"acorn": "^8.13.0",
"acorn-walk": "^8.3.4",
"ansi-styles": "^6.2.1",
"args-tokenizer": "^0.2.1",
"args-tokenizer": "^0.3.0",
"arrify": "^3.0.0",
"callsites": "^4.2.0",
"cbor": "^9.0.2",
Expand Down Expand Up @@ -151,6 +151,5 @@
},
"volta": {
"node": "22.10.0"
},
"packageManager": "[email protected]+sha512.76e2379760a4328ec4415815bcd6628dee727af3779aaa4c914e3944156c4299921a89f976381ee107d41f12cfa4b66681ca9c718f0668fa0831ed4c6d8ba56c"
}
}
6 changes: 3 additions & 3 deletions test/node-arguments/snapshots/test.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ Generated by [AVA](https://avajs.dev).
},
]

## forgive incomplete --node-arguments
## detects incomplete --node-arguments

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

## reads node arguments from config

Expand Down
Binary file modified test/node-arguments/snapshots/test.js.snap
Binary file not shown.
6 changes: 3 additions & 3 deletions test/node-arguments/test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import test from '@ava/test';

import {cwd, fixture} from '../helpers/exec.js';
import {cleanOutput, cwd, fixture} from '../helpers/exec.js';

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

test('forgive incomplete --node-arguments', async t => {
test('detects incomplete --node-arguments', async t => {
const options = {
cwd: cwd('node-arguments'),
};

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

t.snapshot(result.stats.passed, 'tests pass');
t.snapshot(cleanOutput(result.stderr), 'fails with message');
});

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

0 comments on commit 3566d40

Please sign in to comment.