Closed shadowspawn closed 2 years ago
// es6.mjs
import { parseArgs } from '@pkgjs/parseargs';
const result = parseArgs();
console.log(result);
$ node es6.mjs
{
args: {},
values: {},
positionals: [
'/Users/john/Documents/Sandpits/pkgjs/parseargs-issues/play/es6.mjs'
]
}
@shadowspawn this seems good to fix 👍 commented on your PR.
Fixed by #20
https://github.com/pkgjs/parseargs/blob/886e99c1d5dc1b37a004d31a8b201a186c564354/index.js#L4
I assume this line is intended to emulate the proposed
process.mainArgs
and get the slice right when called from the nodeREPL
and/or with--eval
.However, when the script being executed is es6 (
.mjs
) thenrequire.main
isundefined
and it slices incorrectly. Tested using node v16.13.0.(I can refrain from posting bug reports if inappropriate for "early WIP"!)