You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
891 B

  1. /*
  2. * grunt-contrib-clean
  3. * http://gruntjs.com/
  4. *
  5. * Copyright (c) 2012 Tim Branyen, contributors
  6. * Licensed under the MIT license.
  7. */
  8. 'use strict';
  9. module.exports = function(grunt) {
  10. grunt.registerMultiTask('clean', 'Clean files and folders.', function() {
  11. // Merge task-specific and/or target-specific options with these defaults.
  12. var options = this.options({
  13. force: false
  14. });
  15. grunt.verbose.writeflags(options, 'Options');
  16. // Clean specified files / dirs.
  17. this.filesSrc.forEach(function(filepath) {
  18. if (!grunt.file.exists(filepath)) { return; }
  19. grunt.log.write('Cleaning "' + filepath + '"...');
  20. try {
  21. grunt.file.delete(filepath, options);
  22. grunt.log.ok();
  23. } catch (e) {
  24. grunt.log.error();
  25. grunt.verbose.error(e);
  26. grunt.fail.warn('Clean operation failed.');
  27. }
  28. });
  29. });
  30. };