utils.js 769 B

123456789101112131415161718192021222324252627282930
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. 'use strict';
  6. const path = require( 'path' );
  7. const del = require( 'del' );
  8. const gutil = require( 'gulp-util' );
  9. const utils = {
  10. /**
  11. * Removes files and directories specified by `glob` starting from `rootDir`
  12. * and gently informs about deletion.
  13. *
  14. * @param {String} rootDir The path to the root directory (i.e. "dist/").
  15. * @param {String} glob Glob specifying what to clean.
  16. * @returns {Promise}
  17. */
  18. clean( rootDir, glob ) {
  19. return del( path.join( rootDir, glob ) ).then( paths => {
  20. paths.forEach( p => {
  21. gutil.log( `Deleted file '${ gutil.colors.cyan( p ) }'.` );
  22. } );
  23. } );
  24. }
  25. };
  26. module.exports = utils;