From beca3eac558db26f7aa3a8daec10ce99fe294b9a Mon Sep 17 00:00:00 2001 From: naskya Date: Mon, 6 Nov 2023 10:30:00 +0900 Subject: [PATCH] fix: make clean/dev commands work --- package.json | 6 +++--- scripts/{clean-all.js => clean-all.mjs} | 9 ++++++--- scripts/{clean.js => clean.mjs} | 8 +++++--- scripts/{dev.js => dev.mjs} | 18 +++++++++++------- 4 files changed, 25 insertions(+), 16 deletions(-) rename scripts/{clean-all.js => clean-all.mjs} (88%) rename scripts/{clean.js => clean.mjs} (80%) rename scripts/{dev.js => dev.mjs} (67%) diff --git a/package.json b/package.json index 99f6c356..4a05e9ee 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 e3394f40..f8708f74 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 455c4362..aa2d0f73 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 0d6a05fe..beaa11f8 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, });