From 17c9ffe10733f987f8d86396c47d08f4e49abda8 Mon Sep 17 00:00:00 2001 From: n1474335 Date: Wed, 16 Oct 2019 16:32:06 +0100 Subject: [PATCH] Tidied up chainCommands function in Gruntfile --- Gruntfile.js | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index ce4dd863..b25553b7 100755 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -14,18 +14,6 @@ const path = require("path"); * @license Apache-2.0 */ -const chainCommands = function(cmds) { - const win = process.platform === "win32"; - if (!win) { - return cmds.join(";"); - } - return cmds - // Chain Command is different here - .join("&&") - // Windows does not support \n properly - .replace("\n", "\\n"); -}; - module.exports = function (grunt) { grunt.file.defaultEncoding = "utf8"; grunt.file.preserveBOM = false; @@ -113,6 +101,26 @@ module.exports = function (grunt) { return entryModules; } + /** + * Detects the correct delimiter to use to chain shell commands together + * based on the current OS. + * + * @param {string[]} cmds + * @returns {string} + */ + function chainCommands(cmds) { + const win = process.platform === "win32"; + if (!win) { + return cmds.join(";"); + } + return cmds + // && means that subsequent commands will not be executed if the + // previous one fails. & would coninue on a fail + .join("&&") + // Windows does not support \n properly + .replace("\n", "\\n"); + } + grunt.initConfig({ clean: { dev: ["build/dev/*"],