我正在尝试从 grunt 的 scripts.postinstall 运行多个 CLI 命令。我不知道如何让两者都运行。如果我添加第二个命令都不会运行。它们分别在安装后和控制台中工作。
我已经尝试将它们包装在一个数组中:
"scripts": {
"postinstall": ["node_modules/.bin/bower install", "grunt setup"]
},
我尝试用分号分隔它们:
"scripts": {
"postinstall": "node_modules/.bin/bower install; grunt setup"
},
我似乎在 NPM Scripts 上找不到解决方案
这些部分的 gruntfile.js 如下所示:
mkdir: {
setup: {
options: {
create: [
'app/main/source/www', 'app/main/build', 'app/main/docs', 'app/main/tests',
'app/development',
'app/releases'
]
}
}
}
grunt.registerTask('setup', [
'mkdir:setup',
'bowercopy:wordpress'
]);
如果有帮助,这里是我的 package.json 的精简版本,我剪掉了上面的代码示例,主要是为了提供上下文。
{
"name": "webapp",
"version": "0.1.0",
"description": "A web app using bower and grunt",
"main": "gruntfile.js",
"scripts": {
"postinstall": "node_modules/.bin/bower install"
},
"repository": {
"type": "git",
"url": "someurl.com"
},
"keywords": [
"web", "app"
],
"author": {
"company": "somecompany",
"name": "somename",
"email": "email@me.com"
},
"license": "MIT",
"homepage": "https://someurl.com",
"bugs": {
"url": "someurl.com"
},
"devDependencies": {
"grunt": "^0.4.5",
"bower" : "~1.3.5",
etc
}
}
最佳答案
您可以使用 && 在 npm 脚本部分运行多个命令
"scripts": {
"postinstall": "bower install && grunt setup"
},
关于javascript - 你如何运行多个 grunt scripts.postinstall?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24440792/