summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorBilly Biggs <[email protected]>2025-06-14 22:30:00 -0700
committerGitHub <[email protected]>2025-06-15 05:30:00 +0000
commite717c51aa1e46d1a1aabdb7e770c248b93e437a6 (patch)
tree2a1609f0e09a01688b42490f310ea40174ac6599 /scripts
parent53753f0455458dda4055f42ca9caf3aa898bc3c4 (diff)
Avoid import.meta.dirname to be backwards compatible to Node.js 18+ (#1058)
Diffstat (limited to 'scripts')
-rw-r--r--scripts/build.js6
-rw-r--r--scripts/clean.js6
-rw-r--r--scripts/copy_bundle_assets.js6
-rw-r--r--scripts/generate-git-commit-info.js6
-rw-r--r--scripts/start.js6
5 files changed, 20 insertions, 10 deletions
diff --git a/scripts/build.js b/scripts/build.js
index 373e268e..f43a0645 100644
--- a/scripts/build.js
+++ b/scripts/build.js
@@ -20,9 +20,11 @@
import { execSync } from 'child_process';
import { existsSync } from 'fs';
-import { join } from 'path';
+import { dirname, join } from 'path';
+import { fileURLToPath } from 'url';
-const root = join(import.meta.dirname, '..');
+const __dirname = dirname(fileURLToPath(import.meta.url));
+const root = join(__dirname, '..');
// npm install if node_modules was removed (e.g. via npm run clean or scripts/clean.js)
if (!existsSync(join(root, 'node_modules'))) {
diff --git a/scripts/clean.js b/scripts/clean.js
index dd2911e9..51073edf 100644
--- a/scripts/clean.js
+++ b/scripts/clean.js
@@ -19,9 +19,11 @@
import { execSync } from 'child_process';
import { rmSync } from 'fs';
-import { join } from 'path';
+import { dirname, join } from 'path';
+import { fileURLToPath } from 'url';
-const root = join(import.meta.dirname, '..');
+const __dirname = dirname(fileURLToPath(import.meta.url));
+const root = join(__dirname, '..');
// remove npm install/build artifacts
rmSync(join(root, 'node_modules'), { recursive: true, force: true });
diff --git a/scripts/copy_bundle_assets.js b/scripts/copy_bundle_assets.js
index cb1ac197..e37e1700 100644
--- a/scripts/copy_bundle_assets.js
+++ b/scripts/copy_bundle_assets.js
@@ -18,10 +18,12 @@
// limitations under the License.
import { copyFileSync, existsSync, mkdirSync } from 'fs';
-import { join, basename } from 'path';
+import { dirname, join, basename } from 'path';
+import { fileURLToPath } from 'url';
import { glob } from 'glob';
-const root = join(import.meta.dirname, '..');
+const __dirname = dirname(fileURLToPath(import.meta.url));
+const root = join(__dirname, '..');
const bundleDir = join(root, 'bundle');
// Create the bundle directory if it doesn't exist
diff --git a/scripts/generate-git-commit-info.js b/scripts/generate-git-commit-info.js
index f046a7fb..237ec09b 100644
--- a/scripts/generate-git-commit-info.js
+++ b/scripts/generate-git-commit-info.js
@@ -19,9 +19,11 @@
import { execSync } from 'child_process';
import { existsSync, mkdirSync, writeFileSync } from 'fs';
-import { join } from 'path';
+import { dirname, join } from 'path';
+import { fileURLToPath } from 'url';
-const root = join(import.meta.dirname, '..');
+const __dirname = dirname(fileURLToPath(import.meta.url));
+const root = join(__dirname, '..');
const generatedDir = join(root, 'packages/cli/src/generated');
const gitCommitFile = join(generatedDir, 'git-commit.ts');
let gitCommitInfo = 'N/A';
diff --git a/scripts/start.js b/scripts/start.js
index 16b8cb6c..64dccd76 100644
--- a/scripts/start.js
+++ b/scripts/start.js
@@ -18,10 +18,12 @@
// limitations under the License.
import { spawn, execSync } from 'child_process';
-import { join } from 'path';
+import { dirname, join } from 'path';
+import { fileURLToPath } from 'url';
import { readFileSync } from 'fs';
-const root = join(import.meta.dirname, '..');
+const __dirname = dirname(fileURLToPath(import.meta.url));
+const root = join(__dirname, '..');
const pkg = JSON.parse(readFileSync(join(root, 'package.json'), 'utf-8'));
// check build status, write warnings to file for app to display if needed