Created
June 25, 2021 05:26
-
-
Save souporserious/a1609bea075ebf21d6f6056b00e7eee0 to your computer and use it in GitHub Desktop.
Parse Node args using Object.fromEntries.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const args = Object.fromEntries( | |
process.argv.slice(2).map((arg) => { | |
const [key, value] = arg.split('=') | |
return [key.slice(2), value] | |
}) | |
) | |
// input: --port=3000 --out=dist | |
// output: { port: '3000', out: 'dist' } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment