A node library for deleting a path if exists using del.
npm i clear-path --save-dev
# package.json
{
"scripts": {
"clean": "clear-path"
},
"clearpath": "dist"
}
The clearpath
value can a string, or an array of glob patterns strings.
You must add a configuration either within package.json
, or creating a .clearpathrc
{
"clearpath": [
"dist/*.png",
"dist/*.jpg"
],
}
dist/*.png
dist/*.jpg
const clearPath = require( "clear-path" );
clearPath("dist");
clearPath("dist", {
silent: true,
callback: (files) => {
console.log("Deleted theses files: ", files)
}
})
Default: false
If set to true, will not console log deleted files.
You can activate options.silent from cli commands using
clear-path --silent
orclear-path --routine:{routine_name} --silent
If you declara a function in your options.callback
, it will execute after deleting files.
Chose either one of the configurations samples below.
# package.json
{
"scripts": {
"clean": "clear-path --routine=all",
"clean:dist": "clear-path --routine=dist"
},
"clearpath": {
"routine": {
"all": [
"dist",
"public"
],
"dist": "dist",
}
}
}
routine:
all:
dist
public
dist: dist