如何使用npm清理(删除内容)文件夹 [英] How to clean (delete contents) folder with npm

查看:451
本文介绍了如何使用npm清理(删除内容)文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试部署一个Web项目,为此,在构建它之前,需要清除 dist 文件夹。

I am trying to deploy a web project, for that, before build it, I need to clear the dist folder.

当然,我可以添加一个运行 rm -rf dist / * 的脚本,但是某些使用Windows的用户将无法运行它。

Of course I could add a script that would run rm -rf dist/* but some users with Windows won't be able to run it.

是否有一些npm软件包会使用命令删除文件夹?

Is there some npm package that would delete a folder with a command?

推荐答案

您可以使用 rimraf https://github.com / isaacs / rimraf

请注意,如果您使用的是包含globstar的glob( ** ),您必须 将双引号引起来。 Unix系统默认情况下并不全都支持globstar,但是 rimraf 会为您扩展它们。 Windows不支持单引号,因此不能使用它们。请记住,必须在JSON中使用 \ 对双引号进行转义。

Note that if you are using globs containing the globstar (**), you must double-quote them. Unix systems don't all support the globstar by default, but rimraf will expand them for you. Windows doesn't support single-quotes, so those can't be used. Remember that double-quotes must be escaped in JSON with a \.

这篇关于如何使用npm清理(删除内容)文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆