Node.js 如何编写跨平台工作的grunt shell任务?
我正试图编写一个grunt任务来删除目录及其内容 这里是配置文件Node.js 如何编写跨平台工作的grunt shell任务?,node.js,shell,gruntjs,Node.js,Shell,Gruntjs,我正试图编写一个grunt任务来删除目录及其内容 这里是配置文件 { "name": "lorem", "homepage": "ipsum", "version": "0.9.5", "devDependencies": { "grunt": "^0.4.5", "grunt-shell": "~0.5.0", } } 和grunt.js文件 // Whole Gruntfile.js so far module.exports = function(gr
{
"name": "lorem",
"homepage": "ipsum",
"version": "0.9.5",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-shell": "~0.5.0",
}
}
和grunt.js文件
// Whole Gruntfile.js so far
module.exports = function(grunt) {
// 1. All configuration goes here
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
shell: {
clean: {
command: 'rm dist -r',
options: { stdout: true, failOnError: true }
}
}
});
grunt.loadNpmTasks('grunt-shell');
grunt.registerTask('default', ['shell:clean']);
};
这可能适用于linux,但是如果机器是windows或osx呢?
有没有跨平台的解决方案?Shell命令使用系统Shell,这在操作系统之间是不同的。如果您想要跨平台的东西,只需在JS中完成即可。至于您的用例,您可以使用,或者。谢谢您的解释。那就行了。将节点用于更复杂的任务将是更好的解决方案。