rmrf.js 522 B

1234567891011121314151617181920
  1. const rimraf = require("rimraf");
  2. module.exports = function(config, item) {
  3. return new Promise(function(resolve, reject) {
  4. if (!config.unsafe && item.path.substring(0, 2) !== "./") {
  5. reject({
  6. message: `path \`${
  7. item.path
  8. }\` is not local to the project. If you're sure you want to do this, set config.unsafe to true.`,
  9. item
  10. });
  11. }
  12. rimraf(item.path, err => {
  13. if (err) {
  14. reject(err);
  15. }
  16. resolve({ ...item, path: null });
  17. });
  18. });
  19. };