@datacamp/learn-vm-scripts 1.8.4 → 1.8.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.
Files changed (2) hide show
  1. package/dist/index.cjs +40 -7
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -366605,7 +366605,10 @@ async function setupPuppeteerPage({
366605
366605
  headless: false,
366606
366606
  defaultViewport: null,
366607
366607
  args: ["--start-maximized", "--enable-save-password-bubble"],
366608
- ignoreDefaultArgs: ["--enable-automation"],
366608
+ ignoreDefaultArgs: [
366609
+ "--enable-automation",
366610
+ "--disable-blink-features=AutomationControlled"
366611
+ ],
366609
366612
  userDataDir
366610
366613
  });
366611
366614
  const pages = await browser.pages();
@@ -367074,9 +367077,10 @@ var handleInput = async ({ line, page }) => {
367074
367077
  default:
367075
367078
  return unreachable(input);
367076
367079
  }
367077
- log("Script ran successfully");
367080
+ return true;
367078
367081
  } catch (error) {
367079
367082
  console.error(`Error: "${error.message}" on input ${line}`);
367083
+ return false;
367080
367084
  }
367081
367085
  };
367082
367086
  var createFileIfNotExists = async (filePath) => {
@@ -367095,6 +367099,9 @@ var startInputWatcher = async ({
367095
367099
  }) => {
367096
367100
  const outputFileHandle = await fs.open(outputFilePath, "a");
367097
367101
  let lastInput = void 0;
367102
+ let lastInputSucceeded = void 0;
367103
+ let processingPromise = void 0;
367104
+ let numberOfRuns = 0;
367098
367105
  await createFileIfNotExists(inputFilePath);
367099
367106
  let page = await setupPuppeteerPage({
367100
367107
  executablePath,
@@ -367108,8 +367115,9 @@ var startInputWatcher = async ({
367108
367115
  log("No input");
367109
367116
  return;
367110
367117
  }
367111
- if (lastInput != null && newInput === lastInput) {
367118
+ if (lastInput != null && newInput === lastInput && lastInputSucceeded === true) {
367112
367119
  log("Input already processed");
367120
+ log("Script ran successfully");
367113
367121
  await outputFileHandle.appendFile(`Done: ${newInput}`);
367114
367122
  return;
367115
367123
  }
@@ -367122,19 +367130,44 @@ var startInputWatcher = async ({
367122
367130
  });
367123
367131
  }
367124
367132
  log("New input, processing");
367125
- await handleInput({ line: newInput, page });
367133
+ const success = await handleInput({ line: newInput, page });
367134
+ lastInput = newInput;
367135
+ if (success) {
367136
+ log("Script ran successfully");
367137
+ lastInputSucceeded = true;
367138
+ } else {
367139
+ log("Script ran unsuccessfully");
367140
+ lastInputSucceeded = false;
367141
+ }
367126
367142
  await outputFileHandle.appendFile(`Done: ${newInput}`);
367127
367143
  log("Done processing input");
367128
- lastInput = newInput;
367129
367144
  };
367130
- await checkInputFile();
367145
+ const run = async () => {
367146
+ numberOfRuns++;
367147
+ const runId = numberOfRuns;
367148
+ if (processingPromise != null) {
367149
+ log(`WARNING: Parallel execution detected!`);
367150
+ await processingPromise;
367151
+ if (runId !== numberOfRuns) {
367152
+ log(`WARNING: Run ${runId} was cancelled`);
367153
+ return;
367154
+ }
367155
+ }
367156
+ try {
367157
+ processingPromise = checkInputFile();
367158
+ await processingPromise;
367159
+ } finally {
367160
+ processingPromise = void 0;
367161
+ }
367162
+ };
367163
+ await run();
367131
367164
  log("Waiting for input");
367132
367165
  for await (const event of fs.watch(inputFilePath)) {
367133
367166
  if (event.eventType !== "change") {
367134
367167
  continue;
367135
367168
  }
367136
367169
  log("Input file changed");
367137
- await checkInputFile();
367170
+ await run();
367138
367171
  }
367139
367172
  };
367140
367173
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datacamp/learn-vm-scripts",
3
- "version": "1.8.4",
3
+ "version": "1.8.6",
4
4
  "repository": "git@github.com:datacamp-engineering/learn-vm-scripts.git",
5
5
  "description": "Scripts used by VMs in learn.",
6
6
  "main": "./dist/index.cjs",