我目前使用 grunt-shell从 grunt 运行 shell 命令任务。除了用 '&&' 将它们串在一起之外,有没有更好的方法在一个任务中运行多个命令?
我的 Gruntfile(部分):
grunt.initConfig({
shell: {
deploy: {
options: { stdout: true },
command: 'mkdir -p static/styles && cp public/styles/main.css static/styles'
}
}
});
一系列命令不起作用,但它会很好:
grunt.initConfig({
shell: {
deploy: {
options: { stdout: true },
command: [
'mkdir -p static/styles',
'cp public/styles/main.css static/styles'
]
}
}
});
最佳答案
您可以将它们结合在一起:
grunt.initConfig({
shell: {
deploy: {
options: { stdout: true },
command: [
'mkdir -p static/styles',
'cp public/styles/main.css static/styles'
].join('&&')
}
}
});
我选择不支持数组的原因是有些人可能希望 ;
作为分隔符而不是 &&
,这样可以更轻松地执行上述操作。
关于node.js - 如何在 gruntjs 任务中运行多个 shell 命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16122549/