Skip to content

Commit 3eb0a6d

Browse files
committed
APP-3602 pipe logs to fix buffer limit
1 parent 969dfe4 commit 3eb0a6d

File tree

2 files changed

+46
-4
lines changed

2 files changed

+46
-4
lines changed

dist/index.js

+23-2
Original file line numberDiff line numberDiff line change
@@ -26177,7 +26177,7 @@ const os = __nccwpck_require__(612);
2617726177
const https = __nccwpck_require__(2286);
2617826178
const stream = __nccwpck_require__(6402);
2617926179
const util = __nccwpck_require__(7261);
26180-
const { spawnSync, SpawnSyncReturns } = __nccwpck_require__(7718); // eslint-disable-line no-unused-vars
26180+
const { spawnSync, SpawnSyncReturns, spawn, ChildProcessWithoutNullStreams } = __nccwpck_require__(7718); // eslint-disable-line no-unused-vars
2618126181
const { getInput } = __nccwpck_require__(2186);
2618226182

2618326183
const platforms = ['linux', 'darwin'];
@@ -26239,6 +26239,27 @@ function checkSpawnSync(result) {
2623926239
}
2624026240
}
2624126241

26242+
/**
26243+
* forward output from child process, crash on error
26244+
* @param {ChildProcessWithoutNullStreams} child
26245+
*/
26246+
async function checkSpawn(child) {
26247+
child.stdout.pipe(process.stdout);
26248+
child.stderr.pipe(process.stderr);
26249+
await new Promise(function (resolve, reject) {
26250+
child.on('close', function (code, signal) {
26251+
if (signal != null) {
26252+
reject(new Error(`terminated with signal ${signal}`));
26253+
}
26254+
if (code == 0) {
26255+
resolve();
26256+
} else {
26257+
reject(new Error(`exited with code ${code}`));
26258+
}
26259+
});
26260+
});
26261+
}
26262+
2624226263
/**
2624326264
* get build-id from start command
2624426265
* @param {Buffer} stdout stdout of 'start' command
@@ -26279,7 +26300,7 @@ function parseBuildId(stdout) {
2627926300
checkSpawnSync(spawnRet);
2628026301
const buildId = parseBuildId(spawnRet.stdout);
2628126302
console.log('waiting for build');
26282-
checkSpawnSync(spawnSync(cliPath, ['module', 'build', 'logs', '--id', buildId, '--wait']));
26303+
await checkSpawn(spawn(cliPath, ['module', 'build', 'logs', '--id', buildId, '--wait']));
2628326304
})();
2628426305

2628526306
})();

src/index.js

+23-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const os = require('node:os');
33
const https = require('node:https');
44
const stream = require('node:stream/promises');
55
const util = require('node:util');
6-
const { spawnSync, SpawnSyncReturns } = require('node:child_process'); // eslint-disable-line no-unused-vars
6+
const { spawnSync, SpawnSyncReturns, spawn, ChildProcessWithoutNullStreams } = require('node:child_process'); // eslint-disable-line no-unused-vars
77
const { getInput } = require('@actions/core');
88

99
const platforms = ['linux', 'darwin'];
@@ -65,6 +65,27 @@ function checkSpawnSync(result) {
6565
}
6666
}
6767

68+
/**
69+
* forward output from child process, crash on error
70+
* @param {ChildProcessWithoutNullStreams} child
71+
*/
72+
async function checkSpawn(child) {
73+
child.stdout.pipe(process.stdout);
74+
child.stderr.pipe(process.stderr);
75+
await new Promise(function (resolve, reject) {
76+
child.on('close', function (code, signal) {
77+
if (signal != null) {
78+
reject(new Error(`terminated with signal ${signal}`));
79+
}
80+
if (code == 0) {
81+
resolve();
82+
} else {
83+
reject(new Error(`exited with code ${code}`));
84+
}
85+
});
86+
});
87+
}
88+
6889
/**
6990
* get build-id from start command
7091
* @param {Buffer} stdout stdout of 'start' command
@@ -105,5 +126,5 @@ function parseBuildId(stdout) {
105126
checkSpawnSync(spawnRet);
106127
const buildId = parseBuildId(spawnRet.stdout);
107128
console.log('waiting for build');
108-
checkSpawnSync(spawnSync(cliPath, ['module', 'build', 'logs', '--id', buildId, '--wait']));
129+
await checkSpawn(spawn(cliPath, ['module', 'build', 'logs', '--id', buildId, '--wait']));
109130
})();

0 commit comments

Comments
 (0)