@timurproko/a1-install 0.2.1-dev.600 → 0.2.1-dev.603
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 +12 -10
- package/package.json +1 -1
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 =
|
|
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 =
|
|
261
|
+
stderrPending = consumeProcessLines(stderrPending, chunk, options.onStderrLine);
|
|
262
262
|
});
|
|
263
263
|
let settled = false;
|
|
264
264
|
child.once("error", error => {
|
|
@@ -360,11 +360,13 @@ async function verifyLaunchers(globalRoot, platform) {
|
|
|
360
360
|
const paths = launcherPaths(globalRoot, platform);
|
|
361
361
|
const entry = resolve(packageRootFor(globalRoot), "bin", "cli.js");
|
|
362
362
|
const expectedSuffix = `${APPLICATION_PACKAGE}/bin/cli.js`;
|
|
363
|
+
let canonicalEntry = null;
|
|
363
364
|
for (const path of paths) {
|
|
364
365
|
try {
|
|
365
366
|
const metadata = await lstat(path);
|
|
366
367
|
if (metadata.isSymbolicLink()) {
|
|
367
|
-
if (
|
|
368
|
+
if (canonicalEntry === null) canonicalEntry = normalizePath(await realpath(entry), platform);
|
|
369
|
+
if (normalizePath(await realpath(path), platform) !== canonicalEntry) throw new Error("launcher target differs");
|
|
368
370
|
} else if (metadata.isFile()) {
|
|
369
371
|
const content = await readFile(path, "utf8");
|
|
370
372
|
if (content.length > 32_768 || !content.replaceAll("\\", "/").includes(expectedSuffix)) throw new Error("launcher content differs");
|