import minimist from 'minimist'
const argv = minimist(process.argv.slice(2))
node ./test.js -a b c --efg abc -d ss sa => { _: [ 'c', 'sa' ], a: 'b', efg: 'abc', d: 'ss' }
或者
const mri = require('mri')
mri(process.argv) => { _:
[ 'C:\Program Files\nodejs\node.exe',
'D:\work\rf-code-shop\test.js',
'c',
'sa' ],
a: 'b',
efg: 'abc',
d: 'ss' }
网友评论