@cdwr/fly-node 0.3.5 → 0.3.6
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/CHANGELOG.md +6 -0
- package/index.cjs +7 -7
- package/index.js +8 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/index.cjs
CHANGED
|
@@ -613,7 +613,7 @@ var SpawnError = class extends Error {
|
|
|
613
613
|
}
|
|
614
614
|
};
|
|
615
615
|
function spawn(command, args, options) {
|
|
616
|
-
return new Promise((
|
|
616
|
+
return new Promise((resolve2, reject) => {
|
|
617
617
|
const { streamToConsole, ...spawnOptions } = options || {};
|
|
618
618
|
const process2 = (0, import_child_process2.spawn)(command, args, {
|
|
619
619
|
...spawnOptions,
|
|
@@ -637,7 +637,7 @@ function spawn(command, args, options) {
|
|
|
637
637
|
const stdout = Buffer.concat(stdoutChunks).toString();
|
|
638
638
|
const stderr = Buffer.concat(stderrChunks).toString();
|
|
639
639
|
if (code === 0) {
|
|
640
|
-
|
|
640
|
+
resolve2({ stdout, stderr });
|
|
641
641
|
} else {
|
|
642
642
|
const lines = stderr.replace(/\r?\n$/, "").split(/\r?\n/);
|
|
643
643
|
const message = streamToConsole && lines.length > STREAMED_STDERR_TAIL_LINES ? `Process exited with code ${code}
|
|
@@ -654,7 +654,7 @@ Error: ${stderr}`;
|
|
|
654
654
|
// libs/shared/util/misc/src/lib/spawn-pty.ts
|
|
655
655
|
var import_node_pty_prebuilt_multiarch = require("@homebridge/node-pty-prebuilt-multiarch");
|
|
656
656
|
function spawnPty(command, args, options) {
|
|
657
|
-
return new Promise((
|
|
657
|
+
return new Promise((resolve2, reject) => {
|
|
658
658
|
const ptyData = [];
|
|
659
659
|
const ptyProcess = (0, import_node_pty_prebuilt_multiarch.spawn)(command, args, {
|
|
660
660
|
cwd: process.cwd(),
|
|
@@ -674,7 +674,7 @@ function spawnPty(command, args, options) {
|
|
|
674
674
|
ptyProcess.onExit(({ exitCode }) => {
|
|
675
675
|
const output = ptyData.join("");
|
|
676
676
|
if (exitCode === 0) {
|
|
677
|
-
|
|
677
|
+
resolve2(output);
|
|
678
678
|
} else {
|
|
679
679
|
reject(
|
|
680
680
|
new Error(`Process exited with code ${exitCode}
|
|
@@ -2141,7 +2141,7 @@ ${error}`);
|
|
|
2141
2141
|
return;
|
|
2142
2142
|
}
|
|
2143
2143
|
await new Promise(
|
|
2144
|
-
(
|
|
2144
|
+
(resolve2) => setTimeout(resolve2, MACHINE_STATE_INTERVAL_MS)
|
|
2145
2145
|
);
|
|
2146
2146
|
}
|
|
2147
2147
|
throw new Error(
|
|
@@ -2317,7 +2317,7 @@ ${JSON.stringify(response, null, 2)}`);
|
|
|
2317
2317
|
async showConfig(onError, options) {
|
|
2318
2318
|
const normalized = this.normalizeOptions(options);
|
|
2319
2319
|
const config = normalized.config || this.instanceConfig;
|
|
2320
|
-
if (config && !(0, import_fs.existsSync)((0, import_path.
|
|
2320
|
+
if (config && !(0, import_fs.existsSync)((0, import_path.resolve)((0, import_process.cwd)(), config))) {
|
|
2321
2321
|
throw new Error(`Config file '${config}' does not exist`);
|
|
2322
2322
|
}
|
|
2323
2323
|
const args = ["config", "show"];
|
|
@@ -2414,7 +2414,7 @@ ${JSON.stringify(response, null, 2)}`);
|
|
|
2414
2414
|
this.logger.info(
|
|
2415
2415
|
`Transient Fly error (${cause}), retrying in ${delay / 1e3}s (attempt ${attempt + 1} of ${TRANSIENT_RETRY_DELAYS_MS.length + 1}): ${toLogCmd}`
|
|
2416
2416
|
);
|
|
2417
|
-
await new Promise((
|
|
2417
|
+
await new Promise((resolve2) => setTimeout(resolve2, delay));
|
|
2418
2418
|
continue;
|
|
2419
2419
|
}
|
|
2420
2420
|
if (onError === "throwOnError") {
|
package/index.js
CHANGED
|
@@ -527,7 +527,7 @@ var HOSTNAME_CHECK_FIELDS = `
|
|
|
527
527
|
|
|
528
528
|
// packages/fly-node/src/lib/fly.class.ts
|
|
529
529
|
import { existsSync, mkdirSync, writeFileSync } from "fs";
|
|
530
|
-
import { dirname, join } from "path";
|
|
530
|
+
import { dirname, join, resolve } from "path";
|
|
531
531
|
import { cwd } from "process";
|
|
532
532
|
|
|
533
533
|
// libs/shared/util/misc/src/lib/docker-build.ts
|
|
@@ -569,7 +569,7 @@ var SpawnError = class extends Error {
|
|
|
569
569
|
}
|
|
570
570
|
};
|
|
571
571
|
function spawn(command, args, options) {
|
|
572
|
-
return new Promise((
|
|
572
|
+
return new Promise((resolve2, reject) => {
|
|
573
573
|
const { streamToConsole, ...spawnOptions } = options || {};
|
|
574
574
|
const process2 = cpSpawn(command, args, {
|
|
575
575
|
...spawnOptions,
|
|
@@ -593,7 +593,7 @@ function spawn(command, args, options) {
|
|
|
593
593
|
const stdout = Buffer.concat(stdoutChunks).toString();
|
|
594
594
|
const stderr = Buffer.concat(stderrChunks).toString();
|
|
595
595
|
if (code === 0) {
|
|
596
|
-
|
|
596
|
+
resolve2({ stdout, stderr });
|
|
597
597
|
} else {
|
|
598
598
|
const lines = stderr.replace(/\r?\n$/, "").split(/\r?\n/);
|
|
599
599
|
const message = streamToConsole && lines.length > STREAMED_STDERR_TAIL_LINES ? `Process exited with code ${code}
|
|
@@ -610,7 +610,7 @@ Error: ${stderr}`;
|
|
|
610
610
|
// libs/shared/util/misc/src/lib/spawn-pty.ts
|
|
611
611
|
import { spawn as spawn2 } from "@homebridge/node-pty-prebuilt-multiarch";
|
|
612
612
|
function spawnPty(command, args, options) {
|
|
613
|
-
return new Promise((
|
|
613
|
+
return new Promise((resolve2, reject) => {
|
|
614
614
|
const ptyData = [];
|
|
615
615
|
const ptyProcess = spawn2(command, args, {
|
|
616
616
|
cwd: process.cwd(),
|
|
@@ -630,7 +630,7 @@ function spawnPty(command, args, options) {
|
|
|
630
630
|
ptyProcess.onExit(({ exitCode }) => {
|
|
631
631
|
const output = ptyData.join("");
|
|
632
632
|
if (exitCode === 0) {
|
|
633
|
-
|
|
633
|
+
resolve2(output);
|
|
634
634
|
} else {
|
|
635
635
|
reject(
|
|
636
636
|
new Error(`Process exited with code ${exitCode}
|
|
@@ -2097,7 +2097,7 @@ ${error}`);
|
|
|
2097
2097
|
return;
|
|
2098
2098
|
}
|
|
2099
2099
|
await new Promise(
|
|
2100
|
-
(
|
|
2100
|
+
(resolve2) => setTimeout(resolve2, MACHINE_STATE_INTERVAL_MS)
|
|
2101
2101
|
);
|
|
2102
2102
|
}
|
|
2103
2103
|
throw new Error(
|
|
@@ -2273,7 +2273,7 @@ ${JSON.stringify(response, null, 2)}`);
|
|
|
2273
2273
|
async showConfig(onError, options) {
|
|
2274
2274
|
const normalized = this.normalizeOptions(options);
|
|
2275
2275
|
const config = normalized.config || this.instanceConfig;
|
|
2276
|
-
if (config && !existsSync(
|
|
2276
|
+
if (config && !existsSync(resolve(cwd(), config))) {
|
|
2277
2277
|
throw new Error(`Config file '${config}' does not exist`);
|
|
2278
2278
|
}
|
|
2279
2279
|
const args = ["config", "show"];
|
|
@@ -2370,7 +2370,7 @@ ${JSON.stringify(response, null, 2)}`);
|
|
|
2370
2370
|
this.logger.info(
|
|
2371
2371
|
`Transient Fly error (${cause}), retrying in ${delay / 1e3}s (attempt ${attempt + 1} of ${TRANSIENT_RETRY_DELAYS_MS.length + 1}): ${toLogCmd}`
|
|
2372
2372
|
);
|
|
2373
|
-
await new Promise((
|
|
2373
|
+
await new Promise((resolve2) => setTimeout(resolve2, delay));
|
|
2374
2374
|
continue;
|
|
2375
2375
|
}
|
|
2376
2376
|
if (onError === "throwOnError") {
|