@varlock/cloudflare-integration 1.0.0 → 1.1.0

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.js CHANGED
@@ -4,7 +4,7 @@ import { patchGlobalConsole } from 'varlock/patch-console';
4
4
  import { patchGlobalServerResponse } from 'varlock/patch-server-response';
5
5
  import { patchGlobalResponse } from 'varlock/patch-response';
6
6
  import { createDebug } from 'varlock';
7
- import { execSyncVarlock } from 'varlock/exec-sync-varlock';
7
+ import { execSyncVarlock, VarlockExecError } from 'varlock/exec-sync-varlock';
8
8
  import { cloudflare } from '@cloudflare/vite-plugin';
9
9
 
10
10
  // ../vite/dist/index.js
@@ -1410,23 +1410,24 @@ var loadCount = 0;
1410
1410
  function reloadConfig(cwd) {
1411
1411
  debug("loading config - count =", ++loadCount, cwd ? `(cwd: ${cwd})` : "");
1412
1412
  try {
1413
- const execResult = execSyncVarlock("load --format json-full --compact", {
1413
+ const { stdout } = execSyncVarlock("load --format json-full --compact", {
1414
+ fullResult: true,
1414
1415
  env: originalProcessEnv,
1415
1416
  ...cwd && { cwd }
1416
1417
  });
1417
- process.env.__VARLOCK_ENV = execResult;
1418
- varlockLoadedEnv = JSON.parse(process.env.__VARLOCK_ENV);
1418
+ process.env.__VARLOCK_ENV = stdout;
1419
+ varlockLoadedEnv = JSON.parse(stdout);
1419
1420
  configIsValid = true;
1420
1421
  } catch (err) {
1421
- const errAny = err;
1422
- const stdout = errAny?.stdout?.toString();
1423
- if (stdout) {
1424
- try {
1425
- varlockLoadedEnv = JSON.parse(stdout);
1426
- } catch {
1422
+ if (err instanceof VarlockExecError) {
1423
+ if (err.stdout) {
1424
+ try {
1425
+ varlockLoadedEnv = JSON.parse(err.stdout);
1426
+ } catch {
1427
+ }
1427
1428
  }
1429
+ if (err.stderr) console.error(err.stderr);
1428
1430
  }
1429
- if (errAny?.stderr) console.error(errAny.stderr.toString());
1430
1431
  configIsValid = false;
1431
1432
  resetStaticReplacements();
1432
1433
  return;
@@ -1687,7 +1688,7 @@ function varlockCloudflareVitePlugin(cloudflareOptions) {
1687
1688
  userResult = userConfig;
1688
1689
  }
1689
1690
  if (!isDevMode) return userResult;
1690
- const serializedGraph = execSyncVarlock("load --format json-full --compact");
1691
+ const { stdout: serializedGraph } = execSyncVarlock("load --format json-full --compact", { fullResult: true });
1691
1692
  let graph;
1692
1693
  try {
1693
1694
  graph = JSON.parse(serializedGraph);