简体   繁体   中英

how to pass parameter from one script to another script in `package.json`?

I'd like to create below scripts in package.json . The script upload is a general command to upload to s3 bucket. It accepts bucket name as a parameter. Other two scripts pass in different bucket name for uploading. Below code doesn't work as expected. How can I make the script work for this case?

scripts: {
    "upload": "aws s3 cp build s3://$1 --grants",
    "upload:dev": "npm run upload -- test",
    "upload:prod": "npm run upload -- prod"
}

You could use the following:

"scripts": {
    "upload": "aws s3 cp build s3://$npm_config_bucket --grants",
    "upload:dev": "npm run upload --bucket=test",
    "upload:prod": "npm run upload --bucket=prod"
},

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM