I want to execute aws-vault
with 2 arguments as a script in my package.json
. Therfore I created a little helper script:
deploy.js
const { spawn } = require('child_process');
const args = process.argv.slice(2);
const child = spawn(
`aws-vault exec ${args[0]} -- sls deploy --stage ${args[1]}`,
);
child.on('close', code => {
console.log(`aws-vault process exited with code ${code}`);
});
and in my package.json
the script is defined like this:
"scripts": {
"start": "serverless offline --httpPort=4000",
"deploy": "node deploy.js $@"}
but when I run yarn deploy myprofile mystage
I receive the following error:
errno: -2,
code: 'ENOENT',
syscall: 'spawn aws-vault exec myprofile -- sls deploy --stage mystage',
path: 'aws-vault exec myprofile -- sls deploy --stage mystage',
spawnargs: []
I am not sure what I missed... the command looks correct
you can set the { shell: true }
and try again.
const child = spawn(
`aws-vault exec ${args[0]} -- sls deploy --stage ${args[1]}`,
[],
{ shell: true }
);