如何在gruntjs任务中运行MULTIPLE shell命令?
我目前使用grunt-shell从一个咕 task任务运行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' ] } } });
你可以一起join:
grunt.initConfig({ shell: { deploy: { options: { stdout: true }, command: [ 'mkdir -p static/styles', 'cp public/styles/main.css static/styles' ].join('&&') } } });
我select不支持数组的原因是有些人可能想要;
作为分隔符而不是&&
,这样做更容易做到以上。