MM-54325 Have web app build script return error codes on failure (#24723)
* MM-54325 Have web app build script return error codes on failure * Make web app --runner option not return an error code
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
bb4aa764bc
Коммит
421fe4b5f0
@@ -6,7 +6,7 @@
|
|||||||
const chalk = require('chalk');
|
const chalk = require('chalk');
|
||||||
const concurrently = require('concurrently');
|
const concurrently = require('concurrently');
|
||||||
|
|
||||||
const {getPlatformCommands} = require('./utils.js');
|
const {getExitCode, getPlatformCommands} = require('./utils.js');
|
||||||
|
|
||||||
async function buildAll() {
|
async function buildAll() {
|
||||||
console.log(chalk.inverse.bold('Building subpackages...') + '\n');
|
console.log(chalk.inverse.bold('Building subpackages...') + '\n');
|
||||||
@@ -20,9 +20,9 @@ async function buildAll() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await result;
|
await result;
|
||||||
} catch (e) {
|
} catch (closeEvents) {
|
||||||
console.error(chalk.inverse.bold.red('Failed to build subpackages'), e);
|
console.error(chalk.inverse.bold.red('Failed to build subpackages'), closeEvents);
|
||||||
return;
|
return getExitCode(closeEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('\n' + chalk.inverse.bold('Subpackages built! Building web app...') + '\n');
|
console.log('\n' + chalk.inverse.bold('Subpackages built! Building web app...') + '\n');
|
||||||
@@ -34,12 +34,15 @@ async function buildAll() {
|
|||||||
{command: 'npm:build --workspace=channels', name: 'webapp', prefixColor: 'cyan'},
|
{command: 'npm:build --workspace=channels', name: 'webapp', prefixColor: 'cyan'},
|
||||||
]);
|
]);
|
||||||
await result;
|
await result;
|
||||||
} catch (e) {
|
} catch (closeEvents) {
|
||||||
console.error(chalk.inverse.bold.red('Failed to build web app'), e);
|
console.error(chalk.inverse.bold.red('Failed to build web app'), closeEvents);
|
||||||
return;
|
return getExitCode(closeEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('\n' + chalk.inverse.bold('Web app built! '));
|
console.log('\n' + chalk.inverse.bold('Web app built!'));
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
buildAll();
|
buildAll().then((exitCode) => {
|
||||||
|
process.exitCode = exitCode;
|
||||||
|
});
|
||||||
|
|||||||
@@ -25,7 +25,16 @@ async function watchAllWithDevServer() {
|
|||||||
killOthers: 'failure',
|
killOthers: 'failure',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let exitCode = 0;
|
||||||
|
try {
|
||||||
await result;
|
await result;
|
||||||
|
} catch (closeEvents) {
|
||||||
|
exitCode = getExitCode(closeEvents, 0);
|
||||||
|
}
|
||||||
|
return exitCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
watchAllWithDevServer();
|
watchAllWithDevServer().then((exitCode) => {
|
||||||
|
process.exit(exitCode);
|
||||||
|
});
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const chalk = require('chalk');
|
|||||||
const concurrently = require('concurrently');
|
const concurrently = require('concurrently');
|
||||||
|
|
||||||
const {makeRunner} = require('./runner.js');
|
const {makeRunner} = require('./runner.js');
|
||||||
const {getPlatformCommands} = require('./utils.js');
|
const {getExitCode, getPlatformCommands} = require('./utils.js');
|
||||||
|
|
||||||
async function watchAll(useRunner) {
|
async function watchAll(useRunner) {
|
||||||
if (!useRunner) {
|
if (!useRunner) {
|
||||||
@@ -41,9 +41,18 @@ async function watchAll(useRunner) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let exitCode = 0;
|
||||||
|
try {
|
||||||
await result;
|
await result;
|
||||||
|
} catch (closeEvents) {
|
||||||
|
exitCode = getExitCode(closeEvents, 0);
|
||||||
|
}
|
||||||
|
return exitCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
const useRunner = process.argv[2] === '--runner' || process.env.MM_USE_WEBAPP_RUNNER;
|
const useRunner = process.argv[2] === '--runner' || process.env.MM_USE_WEBAPP_RUNNER;
|
||||||
|
|
||||||
watchAll(useRunner);
|
watchAll(useRunner).then((exitCode) => {
|
||||||
|
process.exit(exitCode);
|
||||||
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,21 @@ function getColorForWorkspace(workspace) {
|
|||||||
return index === -1 ? chalk.white : workspaceColors[index % workspaceColors.length];
|
return index === -1 ? chalk.white : workspaceColors[index % workspaceColors.length];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {import("concurrently").CloseEvent[]} closeEvents - An array of CloseEvents thrown by concurrently when waiting on a result
|
||||||
|
* @param {number} codeOnSignal - Which error code to return when the process is interrupted
|
||||||
|
*/
|
||||||
|
function getExitCode(closeEvents, codeOnSignal = 1) {
|
||||||
|
const exitCode = closeEvents.find((event) => !event.killed && event.exitCode > 0)?.exitCode;
|
||||||
|
|
||||||
|
if (typeof exitCode === 'string') {
|
||||||
|
return codeOnSignal
|
||||||
|
} else {
|
||||||
|
return exitCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
getExitCode,
|
||||||
getPlatformCommands,
|
getPlatformCommands,
|
||||||
};
|
};
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user