I want to do semi automation to create user for my api, so I have this script
//getUserInfo.js
const argv = require('yargs-parser')(process.argv.slice(2))
module.exports = (async () => {
let [ userId ] = argv._ //parsing...
if(!userId){
console.log('userId is not defined')
return
}
userId = userId.split('=')[1] ////parsing, again :(
console.log(userId) //123
//proceed with automation steps
...
...
})()
The script is working, so in my package.json
I have this
"scripts": {
"admin:getUserInfo": "node server/scripts/getUserInfo.js"
}
All I need to do is to run npm run admin:getUserInfo userId=123
and I can get 123 in my terminal.
But the problem is I have to do so many step just to get the userId value.