Skip to content

Commit

Permalink
APP-3602 pipe logs to fix buffer limit
Browse files Browse the repository at this point in the history
  • Loading branch information
abe-winter committed Jan 13, 2024
1 parent 969dfe4 commit 3eb0a6d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
25 changes: 23 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26177,7 +26177,7 @@ const os = __nccwpck_require__(612);
const https = __nccwpck_require__(2286);
const stream = __nccwpck_require__(6402);
const util = __nccwpck_require__(7261);
const { spawnSync, SpawnSyncReturns } = __nccwpck_require__(7718); // eslint-disable-line no-unused-vars
const { spawnSync, SpawnSyncReturns, spawn, ChildProcessWithoutNullStreams } = __nccwpck_require__(7718); // eslint-disable-line no-unused-vars
const { getInput } = __nccwpck_require__(2186);

const platforms = ['linux', 'darwin'];
Expand Down Expand Up @@ -26239,6 +26239,27 @@ function checkSpawnSync(result) {
}
}

/**
* forward output from child process, crash on error
* @param {ChildProcessWithoutNullStreams} child
*/
async function checkSpawn(child) {
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);
await new Promise(function (resolve, reject) {
child.on('close', function (code, signal) {
if (signal != null) {
reject(new Error(`terminated with signal ${signal}`));
}
if (code == 0) {
resolve();
} else {
reject(new Error(`exited with code ${code}`));
}
});
});
}

/**
* get build-id from start command
* @param {Buffer} stdout stdout of 'start' command
Expand Down Expand Up @@ -26279,7 +26300,7 @@ function parseBuildId(stdout) {
checkSpawnSync(spawnRet);
const buildId = parseBuildId(spawnRet.stdout);
console.log('waiting for build');
checkSpawnSync(spawnSync(cliPath, ['module', 'build', 'logs', '--id', buildId, '--wait']));
await checkSpawn(spawn(cliPath, ['module', 'build', 'logs', '--id', buildId, '--wait']));
})();

})();
Expand Down
25 changes: 23 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const os = require('node:os');
const https = require('node:https');
const stream = require('node:stream/promises');
const util = require('node:util');
const { spawnSync, SpawnSyncReturns } = require('node:child_process'); // eslint-disable-line no-unused-vars
const { spawnSync, SpawnSyncReturns, spawn, ChildProcessWithoutNullStreams } = require('node:child_process'); // eslint-disable-line no-unused-vars
const { getInput } = require('@actions/core');

const platforms = ['linux', 'darwin'];
Expand Down Expand Up @@ -65,6 +65,27 @@ function checkSpawnSync(result) {
}
}

/**
* forward output from child process, crash on error
* @param {ChildProcessWithoutNullStreams} child
*/
async function checkSpawn(child) {
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);
await new Promise(function (resolve, reject) {
child.on('close', function (code, signal) {
if (signal != null) {
reject(new Error(`terminated with signal ${signal}`));
}
if (code == 0) {
resolve();
} else {
reject(new Error(`exited with code ${code}`));
}
});
});
}

/**
* get build-id from start command
* @param {Buffer} stdout stdout of 'start' command
Expand Down Expand Up @@ -105,5 +126,5 @@ function parseBuildId(stdout) {
checkSpawnSync(spawnRet);
const buildId = parseBuildId(spawnRet.stdout);
console.log('waiting for build');
checkSpawnSync(spawnSync(cliPath, ['module', 'build', 'logs', '--id', buildId, '--wait']));
await checkSpawn(spawn(cliPath, ['module', 'build', 'logs', '--id', buildId, '--wait']));
})();

0 comments on commit 3eb0a6d

Please sign in to comment.