Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(scripts): resolve the gate root from the file URL, not URL.pathname

Yudhi Armyndharis01d33c770009
diff --git a/scripts/check-sdk-coverage.mjs b/scripts/check-sdk-coverage.mjs
index fb83e6a52..3f0090712 100644
--- a/scripts/check-sdk-coverage.mjs
+++ b/scripts/check-sdk-coverage.mjs
@@ -27,8 +27,12 @@
*/
import { readFileSync, readdirSync, statSync } from 'node:fs';
import { join } from 'node:path';
+import { fileURLToPath } from 'node:url';
-const root = new URL('../', import.meta.url).pathname;
+// fileURLToPath, not URL.pathname: the latter stays percent-encoded, so a checkout under a path
+// containing a space resolves to a directory that does not exist and every read here fails with
+// ENOENT. check-sdk-docs.mjs and check-chart-behaviour.mjs already resolve it this way.
+const root = fileURLToPath(new URL('../', import.meta.url));
/** Every interpolation form collapses to the same wildcard as an OpenAPI `{param}`. */
const normalize = (path) =>
diff --git a/scripts/check-sdk-events.mjs b/scripts/check-sdk-events.mjs
index 7554aea25..9db8a1120 100644
--- a/scripts/check-sdk-events.mjs
+++ b/scripts/check-sdk-events.mjs
@@ -21,8 +21,12 @@
*/
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
+import { fileURLToPath } from 'node:url';
-const root = new URL('../', import.meta.url).pathname;
+// fileURLToPath, not URL.pathname: the latter stays percent-encoded, so a checkout under a path
+// containing a space resolves to a directory that does not exist and every read here fails with
+// ENOENT. check-sdk-docs.mjs and check-chart-behaviour.mjs already resolve it this way.
+const root = fileURLToPath(new URL('../', import.meta.url));
const read = (...parts) => readFileSync(join(root, ...parts), 'utf8');
const contract = JSON.parse(read('openapi.json'));
diff --git a/scripts/check-sdk-routes.mjs b/scripts/check-sdk-routes.mjs
index 47d0405ad..980d9f81b 100644
--- a/scripts/check-sdk-routes.mjs
+++ b/scripts/check-sdk-routes.mjs
@@ -22,8 +22,12 @@
*/
import { readFileSync, readdirSync, statSync } from 'node:fs';
import { join } from 'node:path';
+import { fileURLToPath } from 'node:url';
-const root = new URL('../', import.meta.url).pathname;
+// fileURLToPath, not URL.pathname: the latter stays percent-encoded, so a checkout under a path
+// containing a space resolves to a directory that does not exist and every read here fails with
+// ENOENT. check-sdk-docs.mjs and check-chart-behaviour.mjs already resolve it this way.
+const root = fileURLToPath(new URL('../', import.meta.url));
/** Every interpolation form the three SDKs use collapses to the same wildcard as an OpenAPI param. */
const normalize = (path) =>