@timurproko/a1-install 0.2.1-dev.599 → 0.2.1-dev.602

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/a1-install.js CHANGED
@@ -231,6 +231,13 @@ function createDefaultProcessRunner(environment, platform) {
231
231
  }
232
232
  }
233
233
 
234
+ export function consumeProcessLines(pending, chunk, callback) {
235
+ const lines = `${pending}${chunk}`.split(/\r?\n/u);
236
+ const trailing = lines.pop() ?? "";
237
+ for (const line of lines) callback?.(line);
238
+ return trailing.slice(-DIAGNOSTIC_LIMIT);
239
+ }
240
+
234
241
  async function runChild(command, args, options) {
235
242
  return await new Promise((resolvePromise, rejectPromise) => {
236
243
  const child = spawn(command, args, {
@@ -243,22 +250,15 @@ async function runChild(command, args, options) {
243
250
  let stderr = "";
244
251
  let stdoutPending = "";
245
252
  let stderrPending = "";
246
- const consume = (stream, chunk, callback) => {
247
- const combined = `${stream}${chunk}`.slice(-DIAGNOSTIC_LIMIT);
248
- const lines = combined.split(/\r?\n/u);
249
- const pending = lines.pop() ?? "";
250
- for (const line of lines) callback?.(line);
251
- return pending;
252
- };
253
253
  child.stdout?.setEncoding("utf8");
254
254
  child.stderr?.setEncoding("utf8");
255
255
  child.stdout?.on("data", chunk => {
256
256
  stdout = `${stdout}${chunk}`.slice(-DIAGNOSTIC_LIMIT);
257
- stdoutPending = consume(stdoutPending, chunk, options.onStdoutLine);
257
+ stdoutPending = consumeProcessLines(stdoutPending, chunk, options.onStdoutLine);
258
258
  });
259
259
  child.stderr?.on("data", chunk => {
260
260
  stderr = `${stderr}${chunk}`.slice(-DIAGNOSTIC_LIMIT);
261
- stderrPending = consume(stderrPending, chunk, options.onStderrLine);
261
+ stderrPending = consumeProcessLines(stderrPending, chunk, options.onStderrLine);
262
262
  });
263
263
  let settled = false;
264
264
  child.once("error", error => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timurproko/a1-install",
3
- "version": "0.2.1-dev.599",
3
+ "version": "0.2.1-dev.602",
4
4
  "description": "Dependency-free installer for a1",
5
5
  "type": "module",
6
6
  "bin": {