rapid
Version:
A simple tool for rapidly creating components
24 lines (22 loc) • 370 B
JavaScript
// dash option capturing
const dash = /^--([^=]+)=(.+)$/;
// dashed arguments
module.exports = Object.assign(
{},
...process.argv.filter(
(arg) => dash.test(arg)
).map(
(arg) => arg.match(dash).slice(1)
).map(
(arg) => ({
[arg[0]]: arg[1]
})
),
...process.argv.filter(
(arg) => !dash.test(arg)
).map(
(arg, index) => ({
[index]: arg
})
)
);