diff --git a/apps/svelte.dev/scripts/get_contributors.js b/apps/svelte.dev/scripts/get_contributors.js index 68f5c33b5f..6624c08aa4 100644 --- a/apps/svelte.dev/scripts/get_contributors.js +++ b/apps/svelte.dev/scripts/get_contributors.js @@ -2,20 +2,18 @@ import 'dotenv/config'; import { Jimp } from 'jimp'; import { stat, writeFile } from 'node:fs/promises'; -import { dirname } from 'node:path'; +import path from 'node:path'; import { fileURLToPath } from 'node:url'; const force = process.env.FORCE_UPDATE === 'true'; -const __dirname = dirname(fileURLToPath(import.meta.url)); -process.chdir(__dirname); - -// ../src/routes/_home/Supporters/contributors.js -const outputFile = new URL(`../src/routes/_home/Supporters/contributors.js`, import.meta.url); +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const out = path.resolve(__dirname, '../src/routes/_home/Supporters/contributors.js'); try { - if (!force && (await stat(outputFile))) { - console.info(`[update/contributors] ${outputFile} exists. Skipping`); + if (!force && (await stat(out))) { + const relative = path.relative(process.cwd(), out); + console.info(`[update/contributors] ${relative} exists. Skipping`); process.exit(0); } } catch { @@ -69,5 +67,5 @@ try { const str = `[\n\t${authors.map((a) => `'${a.login}'`).join(',\n\t')}\n]`; - writeFile(outputFile, `export default ${str};`); + writeFile(out, `export default ${str};`); } diff --git a/apps/svelte.dev/scripts/get_donors.js b/apps/svelte.dev/scripts/get_donors.js index 60773cf4a5..3d07610cb0 100644 --- a/apps/svelte.dev/scripts/get_donors.js +++ b/apps/svelte.dev/scripts/get_donors.js @@ -2,19 +2,18 @@ import 'dotenv/config'; import { Jimp } from 'jimp'; import { stat, writeFile } from 'node:fs/promises'; -import { dirname } from 'node:path'; +import path from 'node:path'; import { fileURLToPath } from 'node:url'; const force = process.env.FORCE_UPDATE === 'true'; -const __dirname = dirname(fileURLToPath(import.meta.url)); -process.chdir(__dirname); - -const outputFile = new URL(`../src/routes/_home/Supporters/donors.js`, import.meta.url); +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const out = path.resolve(__dirname, '../src/routes/_home/Supporters/donors.js'); try { - if (!force && (await stat(outputFile))) { - console.info(`[update/donors] ${outputFile} exists. Skipping`); + if (!force && (await stat(out))) { + const relative = path.relative(process.cwd(), out); + console.info(`[update/donors] ${relative} exists. Skipping`); process.exit(0); } } catch { @@ -65,5 +64,5 @@ try { const str = `[\n\t${included.map((a) => `${JSON.stringify(a.backer.name)}`).join(',\n\t')}\n]`; - writeFile(outputFile, `export default ${str};`); + writeFile(out, `export default ${str};`); } diff --git a/apps/svelte.dev/scripts/get_svelte_template.js b/apps/svelte.dev/scripts/get_svelte_template.js index d525eaa3df..7755af498f 100644 --- a/apps/svelte.dev/scripts/get_svelte_template.js +++ b/apps/svelte.dev/scripts/get_svelte_template.js @@ -1,6 +1,6 @@ // @ts-check import { readdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs'; -import { join } from 'node:path'; +import path from 'node:path'; import { fileURLToPath } from 'node:url'; import { create } from 'sv'; @@ -8,12 +8,15 @@ import { create } from 'sv'; // This is used by the Svelte REPL as part of the "download project" feature const force = process.env.FORCE_UPDATE === 'true'; -const output_file = fileURLToPath(new URL('../static/svelte-template.json', import.meta.url)); -const output_dir = fileURLToPath(new URL('./svelte-template', import.meta.url)); + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const output_file = path.resolve(__dirname, '../static/svelte-template.json'); +const output_dir = path.resolve(__dirname, './svelte-template'); try { if (!force && statSync(output_file)) { - console.info(`[update/template] ${output_file} exists. Skipping`); + const relative = path.relative(process.cwd(), output_file); + console.info(`[update/template] ${relative} exists. Skipping`); process.exit(0); } } catch { @@ -25,7 +28,7 @@ try { const items = readdirSync(dir, { withFileTypes: true }); for (const item of items) { - const full_path = join(dir, item.name); + const full_path = path.join(dir, item.name); if (item.isDirectory()) { files.push(...get_all_files(full_path)); } else { @@ -62,7 +65,7 @@ try { // add CSS styles from playground to the project const html = readFileSync( - join(output_dir, '../../../../packages/repl/src/lib/Output/srcdoc/index.html'), + path.join(output_dir, '../../../../packages/repl/src/lib/Output/srcdoc/index.html'), { encoding: 'utf-8' } ); const css = html