我目前使用grunt-shell从grunt任务运行shell命令.有没有更好的方法在一个任务中运行多个命令,而不是用'&&'将它们串在一起?
我的Gruntfile(部分):
grunt.initConfig({
shell: {
deploy: {
options: { stdout: true },
command: 'mkdir -p static/styles && cp public/styles/main.css static/styles'
}
}
});
Run Code Online (Sandbox Code Playgroud)
一系列命令不起作用,但它会很好:
grunt.initConfig({
shell: {
deploy: {
options: { stdout: true },
command: [
'mkdir -p static/styles',
'cp public/styles/main.css static/styles'
]
}
}
});
Run Code Online (Sandbox Code Playgroud)
Sin*_*hus 15
你可以把它们加在一起:
grunt.initConfig({
shell: {
deploy: {
options: { stdout: true },
command: [
'mkdir -p static/styles',
'cp public/styles/main.css static/styles'
].join('&&')
}
}
});
Run Code Online (Sandbox Code Playgroud)
我选择不支持数组的原因是有些人可能想要;作为分隔符而不是&&,这样可以更容易地完成上述操作.
| 归档时间: |
|
| 查看次数: |
4313 次 |
| 最近记录: |