Updating install and deploy commands for new potential way of distribution
This commit is contained in:
@@ -52,21 +52,34 @@ function runCommandStreaming(
|
|||||||
stdio: ["ignore", "pipe", "pipe"],
|
stdio: ["ignore", "pipe", "pipe"],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const createChunkProcessor = () => {
|
||||||
let leftover = "";
|
let leftover = "";
|
||||||
const processChunk = (chunk: Buffer) => {
|
return {
|
||||||
|
process(chunk: Buffer) {
|
||||||
const text = leftover + chunk.toString();
|
const text = leftover + chunk.toString();
|
||||||
const lines = text.split("\n");
|
// Cargo renders progress with carriage returns when attached to a terminal. Treat both
|
||||||
|
// carriage returns and newlines as line boundaries so build output appears live in Ink.
|
||||||
|
const lines = text.split(/\r\n|\r|\n/);
|
||||||
leftover = lines.pop() || "";
|
leftover = lines.pop() || "";
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
if (line.trim()) onLog(line);
|
if (line.trim()) onLog(line);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
flush() {
|
||||||
|
if (leftover.trim()) onLog(leftover);
|
||||||
|
leftover = "";
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
const stdout = createChunkProcessor();
|
||||||
|
const stderr = createChunkProcessor();
|
||||||
|
|
||||||
child.stdout?.on("data", processChunk);
|
child.stdout?.on("data", (chunk: Buffer) => stdout.process(chunk));
|
||||||
child.stderr?.on("data", processChunk);
|
child.stderr?.on("data", (chunk: Buffer) => stderr.process(chunk));
|
||||||
|
|
||||||
child.on("close", (code) => {
|
child.on("close", (code) => {
|
||||||
if (leftover.trim()) onLog(leftover);
|
stdout.flush();
|
||||||
|
stderr.flush();
|
||||||
if (code === 0) resolve();
|
if (code === 0) resolve();
|
||||||
else reject(new Error(`Command failed with exit code ${code}`));
|
else reject(new Error(`Command failed with exit code ${code}`));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -36,21 +36,34 @@ function runCommandStreaming(
|
|||||||
stdio: ["ignore", "pipe", "pipe"],
|
stdio: ["ignore", "pipe", "pipe"],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const createChunkProcessor = () => {
|
||||||
let leftover = "";
|
let leftover = "";
|
||||||
const processChunk = (chunk: Buffer) => {
|
return {
|
||||||
|
process(chunk: Buffer) {
|
||||||
const text = leftover + chunk.toString();
|
const text = leftover + chunk.toString();
|
||||||
const lines = text.split("\n");
|
// Cargo renders progress with carriage returns when attached to a terminal. Treat both
|
||||||
|
// carriage returns and newlines as line boundaries so build output appears live in Ink.
|
||||||
|
const lines = text.split(/\r\n|\r|\n/);
|
||||||
leftover = lines.pop() || "";
|
leftover = lines.pop() || "";
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
if (line.trim()) onLog(line);
|
if (line.trim()) onLog(line);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
flush() {
|
||||||
|
if (leftover.trim()) onLog(leftover);
|
||||||
|
leftover = "";
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
const stdout = createChunkProcessor();
|
||||||
|
const stderr = createChunkProcessor();
|
||||||
|
|
||||||
child.stdout?.on("data", processChunk);
|
child.stdout?.on("data", (chunk: Buffer) => stdout.process(chunk));
|
||||||
child.stderr?.on("data", processChunk);
|
child.stderr?.on("data", (chunk: Buffer) => stderr.process(chunk));
|
||||||
|
|
||||||
child.on("close", (code) => {
|
child.on("close", (code) => {
|
||||||
if (leftover.trim()) onLog(leftover);
|
stdout.flush();
|
||||||
|
stderr.flush();
|
||||||
if (code === 0) resolve();
|
if (code === 0) resolve();
|
||||||
else reject(new Error(`Command failed with exit code ${code}`));
|
else reject(new Error(`Command failed with exit code ${code}`));
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user