Print log from inner npm run

This commit is contained in:
Linhart Lukáš 2023-10-17 10:45:40 +02:00
parent ba9766fbf0
commit 95190fa424

View File

@ -1,7 +1,7 @@
const os = require('os'); const os = require('os');
const fs = require('fs-extra'); const fs = require('fs-extra');
const util = require('util'); const util = require('util');
const exec = util.promisify(require('child_process').exec); const spawn = util.promisify(require('child_process').spawn);
async function deleteFileIfExists(filePath) { async function deleteFileIfExists(filePath) {
try { try {
@ -46,6 +46,25 @@ async function removeSourceMapFiles(directory) {
} }
} }
async function execCommandWithOutput(command) {
return new Promise(async (resolve, reject) => {
const childProcess = await spawn(command, {
stdio: 'inherit',
shell: true
});
childProcess.on('error', (error) => {
reject(error);
});
childProcess.on('exit', (code) => {
if (code === 0) {
resolve();
} else {
reject(new Error(`Command exited with code ${code}.`));
}
});
});
}
async function main() { async function main() {
try { try {
// Remove out directory // Remove out directory
@ -87,7 +106,7 @@ async function main() {
osArg = 'linux'; osArg = 'linux';
} }
await exec(`npm run dist:${osArg} --workspace=packages/bruno-electron`); await execCommandWithOutput(`npm run dist:${osArg} --workspace=packages/bruno-electron`);
} catch (error) { } catch (error) {
console.error('An error occurred:', error); console.error('An error occurred:', error);
} }