diff options
| author | Tobias Järvelöv <tobias.jarvelov@mullvad.net> | 2025-05-05 17:11:08 +0200 |
|---|---|---|
| committer | Markus Pettersson <markus.pettersson@mullvad.net> | 2025-05-06 11:55:07 +0200 |
| commit | 9dddcce1dc6d0c01149125903dde765c719e85ab (patch) | |
| tree | a58c8e07f6979f1e4030f4a98e0ceb3ff44799e2 | |
| parent | 04d8d667836ae37965550c3f8177822b4d1be26a (diff) | |
| download | mullvadvpn-9dddcce1dc6d0c01149125903dde765c719e85ab.tar.xz mullvadvpn-9dddcce1dc6d0c01149125903dde765c719e85ab.zip | |
Add new utility for running an npm script
| -rw-r--r-- | desktop/packages/mullvad-vpn/tasks/utils.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/desktop/packages/mullvad-vpn/tasks/utils.js b/desktop/packages/mullvad-vpn/tasks/utils.js index 04fefafd00..0b40022d53 100644 --- a/desktop/packages/mullvad-vpn/tasks/utils.js +++ b/desktop/packages/mullvad-vpn/tasks/utils.js @@ -39,6 +39,22 @@ async function removeRecursively(path) { }); } +async function runNpmScript(scriptName) { + const command = `npm run ${scriptName}`; + + try { + await runCommand(command); + } catch (errors) { + if (Array.isArray(errors)) { + // Remove first error as it will always + // bubble up and be printed to the console. + errors.slice(1).forEach((error) => { + console.error(new Error(error)); + }); + } + } +} + async function runCommand(command) { return new Promise((resolve, reject) => { childProcess.exec(command, (error, stdout, stderr) => { @@ -59,4 +75,5 @@ exports.copyRecursively = copyRecursively; exports.getCopyExtensionFilter = getCopyExtensionFilter; exports.removeRecursively = removeRecursively; exports.runCommand = runCommand; +exports.runNpmScript = runNpmScript; exports.setNodeEnvironment = setNodeEnvironment; |
