@patchstack/connect 0.5.23 → 0.5.25

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/protect.js CHANGED
@@ -7082,7 +7082,7 @@ async function createProtection(options = {}) {
7082
7082
  allowHosts
7083
7083
  });
7084
7084
  }
7085
- const cwd = options.cwd ?? (typeof process !== "undefined" ? process.cwd() : void 0);
7085
+ const cwd = workingDirectory(options);
7086
7086
  const live = Boolean(options.siteUuid || options.token);
7087
7087
  const refreshSecret = options.refreshSecret ?? (typeof process !== "undefined" ? process.env.PATCHSTACK_REFRESH_SECRET : void 0);
7088
7088
  const refreshable = live && (options.refreshMs > 0 || Boolean(refreshSecret));
@@ -7176,8 +7176,17 @@ function resolveMode(options, bundle) {
7176
7176
  return "dry-run";
7177
7177
  }
7178
7178
  var CREDENTIAL_FILES = [".patchstackrc.local.json", ".patchstackrc.json"];
7179
+ function workingDirectory(options) {
7180
+ if (options?.cwd !== void 0) return options.cwd;
7181
+ try {
7182
+ return typeof process !== "undefined" && typeof process.cwd === "function" ? process.cwd() : void 0;
7183
+ } catch {
7184
+ return void 0;
7185
+ }
7186
+ }
7179
7187
  async function readCredentialField(options, field) {
7180
- if (typeof process === "undefined" || typeof process.cwd !== "function") return void 0;
7188
+ const cwd = workingDirectory(options);
7189
+ if (!cwd) return void 0;
7181
7190
  let readFileSync;
7182
7191
  let join;
7183
7192
  try {
@@ -7187,7 +7196,6 @@ async function readCredentialField(options, field) {
7187
7196
  } catch {
7188
7197
  return void 0;
7189
7198
  }
7190
- const cwd = options?.cwd ?? process.cwd();
7191
7199
  for (const filename of CREDENTIAL_FILES) {
7192
7200
  try {
7193
7201
  const value = JSON.parse(readFileSync(join(cwd, filename), "utf8"))?.[field];