diff --git a/package.json b/package.json index 99f6c356b..4a05e9ee0 100644 --- a/package.json +++ b/package.json @@ -18,14 +18,14 @@ "migrateandstart": "pnpm run migrate && pnpm run start", "gulp": "gulp build", "watch": "pnpm run dev", - "dev": "pnpm node ./scripts/dev.js", + "dev": "pnpm node ./scripts/dev.mjs", "dev:staging": "NODE_OPTIONS=--max_old_space_size=3072 NODE_ENV=development pnpm run build && pnpm run start", "lint": "pnpm -r --parallel run lint", "debug": "pnpm run build:debug && pnpm run start", "build:debug": "pnpm -r --parallel run build:debug && pnpm run gulp", "format": "pnpm -r --parallel run format", - "clean": "pnpm node ./scripts/clean.js", - "clean-all": "pnpm node ./scripts/clean-all.js", + "clean": "pnpm node ./scripts/clean.mjs", + "clean-all": "pnpm node ./scripts/clean-all.mjs", "cleanall": "pnpm run clean-all" }, "resolutions": { diff --git a/scripts/clean-all.js b/scripts/clean-all.mjs similarity index 88% rename from scripts/clean-all.js rename to scripts/clean-all.mjs index e3394f409..f8708f740 100644 --- a/scripts/clean-all.js +++ b/scripts/clean-all.mjs @@ -1,8 +1,11 @@ -const fs = require("node:fs"); -const execa = require("execa"); -const { join } = require("node:path"); +import fs from "node:fs"; +import path, { join } from "node:path"; +import { fileURLToPath } from "node:url"; +import { execa } from "execa"; (async () => { + const __dirname = path.dirname(fileURLToPath(import.meta.url)); + fs.rmSync(join(__dirname, "/../packages/backend/built"), { recursive: true, force: true, diff --git a/scripts/clean.js b/scripts/clean.mjs similarity index 80% rename from scripts/clean.js rename to scripts/clean.mjs index 455c43628..aa2d0f739 100644 --- a/scripts/clean.js +++ b/scripts/clean.mjs @@ -1,8 +1,10 @@ -const fs = require("node:fs"); -const execa = require("execa"); -const { join } = require("node:path"); +import fs from "node:fs"; +import path, { join } from "node:path"; +import { fileURLToPath } from "node:url"; (async () => { + const __dirname = path.dirname(fileURLToPath(import.meta.url)); + fs.rmSync(join(__dirname, "/../packages/backend/built"), { recursive: true, force: true, diff --git a/scripts/dev.js b/scripts/dev.mjs similarity index 67% rename from scripts/dev.js rename to scripts/dev.mjs index 0d6a05fe2..beaa11f8e 100644 --- a/scripts/dev.js +++ b/scripts/dev.mjs @@ -1,32 +1,36 @@ -const execa = require("execa"); +import path, { join } from "node:path"; +import { fileURLToPath } from "node:url"; +import { execa } from "execa"; (async () => { + const __dirname = path.dirname(fileURLToPath(import.meta.url)); + await execa("pnpm", ["clean"], { - cwd: __dirname + "/../", + cwd: join(__dirname, "/../"), stdout: process.stdout, stderr: process.stderr, }); execa("pnpm", ["dlx", "gulp", "watch"], { - cwd: __dirname + "/../", + cwd: join(__dirname, "/../"), stdout: process.stdout, stderr: process.stderr, }); execa("pnpm", ["--filter", "backend", "watch"], { - cwd: __dirname + "/../", + cwd: join(__dirname, "/../"), stdout: process.stdout, stderr: process.stderr, }); execa("pnpm", ["--filter", "client", "watch"], { - cwd: __dirname + "/../", + cwd: join(__dirname, "/../"), stdout: process.stdout, stderr: process.stderr, }); execa("pnpm", ["--filter", "sw", "watch"], { - cwd: __dirname + "/../", + cwd: join(__dirname, "/../"), stdout: process.stdout, stderr: process.stderr, }); @@ -34,7 +38,7 @@ const execa = require("execa"); const start = async () => { try { await execa("pnpm", ["start"], { - cwd: __dirname + "/../", + cwd: join(__dirname, "/../"), stdout: process.stdout, stderr: process.stderr, });