Преглед изворни кода

Added task allowing for custom shell commands.

Example of use:

    gulp exec --task sh --cmd "sed 's/find/replace' file.js"
Maksymilian Barnaś пре 9 година
родитељ
комит
bc03fadd59
1 измењених фајлова са 30 додато и 0 уклоњено
  1. 30 0
      dev/tasks/exec/functions/sh.js

+ 30 - 0
dev/tasks/exec/functions/sh.js

@@ -0,0 +1,30 @@
+/**
+ * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+'use strict';
+
+const tools = require( '../../../utils/tools' );
+
+/**
+ * Runs custom shell command over each package.
+ *
+ * Example:
+ *
+ *		gulp exec --task sh --cmd "sed 's/find/replace' file.js"
+ *
+ * @param {String} workdir
+ * @param {Object} params
+ */
+module.exports = function executeShellCommand( workdir, params ) {
+	// Needed to see results of commands printing to stdout/stderr.
+	const shouldLogOutput = true;
+	const cmd = params.cmd;
+
+	if ( !cmd ) {
+		throw new Error( 'You must provide command to execute with parameter: --cmd "command"' );
+	}
+
+	tools.shExec( cmd, shouldLogOutput );
+};