Skip to content

Instantly share code, notes, and snippets.

@avisek
Last active April 29, 2022 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avisek/3d6a0404ffc141b008279e65a1ebf1ad to your computer and use it in GitHub Desktop.
Save avisek/3d6a0404ffc141b008279e65a1ebf1ad to your computer and use it in GitHub Desktop.
Delete folders via NPM script

Add below code in package.json script

{
  "scripts": {
     "rmdir": "node -e \"var fs = require('fs'); process.argv.slice(1).map((fpath) => fs.rmdirSync(fpath, { recursive: true })); process.exit(0);\"",
  }
}

Then execute as below in command window

npm run rmdir -- folder1 folder2

To delete one specific folder

{
  "scripts": {
     "clean": "node -e \"require('fs').rmdirSync('css/', { recursive: true }); process.exit(0);\"",
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment