@datacamp/learn-vm-scripts 0.0.1-rc.12 → 0.0.1-rc.14
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/dist/index.cjs +39 -8
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -95426,7 +95426,7 @@ var handleInput = async ({
|
|
|
95426
95426
|
console.error(source_default.red("Unsupported cloud provider"));
|
|
95427
95427
|
}
|
|
95428
95428
|
} catch (error) {
|
|
95429
|
-
console.error(source_default.red(`Error: ${error.message}`));
|
|
95429
|
+
console.error(source_default.red(`Error: "${error.message}" on input ${line}`));
|
|
95430
95430
|
}
|
|
95431
95431
|
};
|
|
95432
95432
|
var createFileIfNotExists = async (filePath) => {
|
|
@@ -95437,6 +95437,22 @@ var createFileIfNotExists = async (filePath) => {
|
|
|
95437
95437
|
await handle.close();
|
|
95438
95438
|
}
|
|
95439
95439
|
};
|
|
95440
|
+
var checkInputFile = async ({
|
|
95441
|
+
inputFilePath,
|
|
95442
|
+
executablePath: executablePath2,
|
|
95443
|
+
userDataDir,
|
|
95444
|
+
outputFileHandle
|
|
95445
|
+
}) => {
|
|
95446
|
+
const fileContent = await fs6.readFile(inputFilePath, { encoding: "utf-8" });
|
|
95447
|
+
const lines = fileContent.split(/\r?\n/);
|
|
95448
|
+
const firstLine = lines[0]?.trim();
|
|
95449
|
+
if (firstLine == null || firstLine === "") {
|
|
95450
|
+
return "no-input";
|
|
95451
|
+
}
|
|
95452
|
+
await handleInput({ line: firstLine, userDataDir, executablePath: executablePath2 });
|
|
95453
|
+
await outputFileHandle.appendFile(`Done: ${firstLine}`);
|
|
95454
|
+
return "done";
|
|
95455
|
+
};
|
|
95440
95456
|
var startInputWatcher = async ({
|
|
95441
95457
|
inputFilePath,
|
|
95442
95458
|
outputFilePath,
|
|
@@ -95445,18 +95461,33 @@ var startInputWatcher = async ({
|
|
|
95445
95461
|
}) => {
|
|
95446
95462
|
const outputFileHandle = await fs6.open(outputFilePath, "a");
|
|
95447
95463
|
await createFileIfNotExists(inputFilePath);
|
|
95464
|
+
const checkInputFileResult = await checkInputFile({
|
|
95465
|
+
inputFilePath,
|
|
95466
|
+
executablePath: executablePath2,
|
|
95467
|
+
userDataDir,
|
|
95468
|
+
outputFileHandle
|
|
95469
|
+
});
|
|
95470
|
+
if (checkInputFileResult === "done") {
|
|
95471
|
+
return;
|
|
95472
|
+
}
|
|
95473
|
+
console.log("Waiting for input");
|
|
95448
95474
|
for await (const event of fs6.watch(inputFilePath)) {
|
|
95449
95475
|
if (event.eventType !== "change") {
|
|
95450
95476
|
continue;
|
|
95451
95477
|
}
|
|
95452
|
-
const
|
|
95453
|
-
|
|
95454
|
-
|
|
95455
|
-
|
|
95456
|
-
|
|
95478
|
+
const checkInputFileResult2 = await checkInputFile({
|
|
95479
|
+
inputFilePath,
|
|
95480
|
+
executablePath: executablePath2,
|
|
95481
|
+
userDataDir,
|
|
95482
|
+
outputFileHandle
|
|
95483
|
+
});
|
|
95484
|
+
switch (checkInputFileResult2) {
|
|
95485
|
+
case "done":
|
|
95486
|
+
return;
|
|
95487
|
+
case "no-input":
|
|
95488
|
+
console.log("Waiting for input");
|
|
95489
|
+
break;
|
|
95457
95490
|
}
|
|
95458
|
-
await handleInput({ line: firstLine, userDataDir, executablePath: executablePath2 });
|
|
95459
|
-
await outputFileHandle.appendFile(`Done: ${firstLine}`);
|
|
95460
95491
|
}
|
|
95461
95492
|
};
|
|
95462
95493
|
|
package/package.json
CHANGED