Skip to content

Commit 99cfeeb

Browse files
committed
chore: tweak build scripts
1 parent fe7c73c commit 99cfeeb

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

apps/svelte.dev/scripts/get_contributors.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,18 @@
22
import 'dotenv/config';
33
import { Jimp } from 'jimp';
44
import { stat, writeFile } from 'node:fs/promises';
5-
import { dirname } from 'node:path';
5+
import path from 'node:path';
66
import { fileURLToPath } from 'node:url';
77

88
const force = process.env.FORCE_UPDATE === 'true';
99

10-
const __dirname = dirname(fileURLToPath(import.meta.url));
11-
process.chdir(__dirname);
12-
13-
// ../src/routes/_home/Supporters/contributors.js
14-
const outputFile = new URL(`../src/routes/_home/Supporters/contributors.js`, import.meta.url);
10+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
11+
const out = path.resolve(__dirname, '../src/routes/_home/Supporters/contributors.js');
1512

1613
try {
17-
if (!force && (await stat(outputFile))) {
18-
console.info(`[update/contributors] ${outputFile} exists. Skipping`);
14+
if (!force && (await stat(out))) {
15+
const relative = path.relative(process.cwd(), out);
16+
console.info(`[update/contributors] ${relative} exists. Skipping`);
1917
process.exit(0);
2018
}
2119
} catch {
@@ -69,5 +67,5 @@ try {
6967

7068
const str = `[\n\t${authors.map((a) => `'${a.login}'`).join(',\n\t')}\n]`;
7169

72-
writeFile(outputFile, `export default ${str};`);
70+
writeFile(out, `export default ${str};`);
7371
}

apps/svelte.dev/scripts/get_donors.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,18 @@
22
import 'dotenv/config';
33
import { Jimp } from 'jimp';
44
import { stat, writeFile } from 'node:fs/promises';
5-
import { dirname } from 'node:path';
5+
import path from 'node:path';
66
import { fileURLToPath } from 'node:url';
77

88
const force = process.env.FORCE_UPDATE === 'true';
99

10-
const __dirname = dirname(fileURLToPath(import.meta.url));
11-
process.chdir(__dirname);
12-
13-
const outputFile = new URL(`../src/routes/_home/Supporters/donors.js`, import.meta.url);
10+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
11+
const out = path.resolve(__dirname, '../src/routes/_home/Supporters/donors.js');
1412

1513
try {
16-
if (!force && (await stat(outputFile))) {
17-
console.info(`[update/donors] ${outputFile} exists. Skipping`);
14+
if (!force && (await stat(out))) {
15+
const relative = path.relative(process.cwd(), out);
16+
console.info(`[update/donors] ${relative} exists. Skipping`);
1817
process.exit(0);
1918
}
2019
} catch {
@@ -65,5 +64,5 @@ try {
6564

6665
const str = `[\n\t${included.map((a) => `${JSON.stringify(a.backer.name)}`).join(',\n\t')}\n]`;
6766

68-
writeFile(outputFile, `export default ${str};`);
67+
writeFile(out, `export default ${str};`);
6968
}

apps/svelte.dev/scripts/get_svelte_template.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
// @ts-check
22
import { readdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
3-
import { join } from 'node:path';
3+
import path from 'node:path';
44
import { fileURLToPath } from 'node:url';
55
import { create } from 'sv';
66

77
// This download the currente Vite template from Github, adjusts it to our needs, and saves it to static/svelte-template.json
88
// This is used by the Svelte REPL as part of the "download project" feature
99

1010
const force = process.env.FORCE_UPDATE === 'true';
11-
const output_file = fileURLToPath(new URL('../static/svelte-template.json', import.meta.url));
12-
const output_dir = fileURLToPath(new URL('./svelte-template', import.meta.url));
11+
12+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
13+
const output_file = path.resolve(__dirname, '../static/svelte-template.json');
14+
const output_dir = path.resolve(__dirname, './svelte-template');
1315

1416
try {
1517
if (!force && statSync(output_file)) {
16-
console.info(`[update/template] ${output_file} exists. Skipping`);
18+
const relative = path.relative(process.cwd(), output_file);
19+
console.info(`[update/template] ${relative} exists. Skipping`);
1720
process.exit(0);
1821
}
1922
} catch {
@@ -25,7 +28,7 @@ try {
2528
const items = readdirSync(dir, { withFileTypes: true });
2629

2730
for (const item of items) {
28-
const full_path = join(dir, item.name);
31+
const full_path = path.join(dir, item.name);
2932
if (item.isDirectory()) {
3033
files.push(...get_all_files(full_path));
3134
} else {

0 commit comments

Comments
 (0)