8
0

sh.js 729 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 tools = require( '../../../utils/tools' );
  7. /**
  8. * Runs custom shell command over each package.
  9. *
  10. * Example:
  11. *
  12. * gulp exec --task sh --cmd "sed 's/find/replace' file.js"
  13. *
  14. * @param {String} workdir
  15. * @param {Object} params
  16. */
  17. module.exports = function executeShellCommand( workdir, params ) {
  18. // Needed to see results of commands printing to stdout/stderr.
  19. const shouldLogOutput = true;
  20. const cmd = params.cmd;
  21. if ( !cmd ) {
  22. throw new Error( 'You must provide command to execute with parameter: --cmd "command"' );
  23. }
  24. tools.shExec( cmd, shouldLogOutput );
  25. };