1

我有一个 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

4

1 回答 1

0

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

chmod: {
  options: {
  mode: '755'
  },
  yourTarget1: {
   src: ['**/*.js']
  }
}
于 2013-06-19T04:12:09.937 回答