sindresorhus / del

Delete files and directories
MIT License
1.33k stars 66 forks source link

why 'del' restores the files I have deleted using 'rimraf' #135

Closed WDYSY closed 3 years ago

WDYSY commented 3 years ago

When building our project, the framework of our team uses del to delete the publish folder, but I find it too slow, so I think maybe I can delete the publish folder before building.

But it does not work for me, after I run "npx rimraf ./**/publish", the publish folder did disapper at once, what is curious for me is that when executing the build script(which runs del to delete publish folder, the code is in pasted after) in our framework, the publish folder reappeared!

`var del = require('del');

module.exports = function build(options) { var config = getConfig(options); return Promise.resolve().then(function () { return delPublish(path.join(config.root, config.publish)); }).then(function () { return startGulp(config); }).then(function () { return Promise.all([startWebpackForClient(config), config.useServerBundle && startWebpackForServer(config)].filter(Boolean)); }).then(function () { return startStaticEntry(config); }).then(function () { console.log('build successfully!'); process.exit(0); })["catch"](function (error) { console.error(error); process.exit(1); }); };

function delPublish(folder) { console.log("delete publish folder: ".concat(folder)); return del(folder); }`