如何删除grunt clean的只读文件?

时间:2013-06-19 03:21:43

标签: build-automation gruntjs

我有一个grunt构建脚本,它有一个clean任务来删除一些缓存文件。目前此任务失败,因为它应该删除的文件是只读的。

如何让grunt clean删除只读文件?

对于那些好奇的人,我的命令输出如下:

Running "clean:templates" (clean) task
Verifying property clean.templates exists in config...OK
Files: app/cache/dev/twig, app/cache/prod/twig -> templates
Options: force
Cleaning "app/cache/dev/twig"...Deleting app/cache/dev/twig...ERROR
ERROR
>> Error: Unable to delete "app/cache/dev/twig" file (EPERM, operation not permitted 'app/cache/dev/twig').
Warning: Clean operation failed. Use --force to continue.

app/cache/dev/twig文件夹中的文件是只读的,可以使用rm -rf app/cache/dev/twig命令删除。

1 个答案:

答案 0 :(得分:0)

可能有更好的方法,但如果您有足够的权限,请尝试: https://github.com/JamesMGreene/grunt-chmod + grunt-contrib-clean?

chmod: {
  options: {
  mode: '755'
  },
  yourTarget1: {
   src: ['**/*.js']
  }
}