|
1 | 1 | // @ts-check
|
2 | 2 | import { readdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
3 |
| -import { join } from 'node:path'; |
| 3 | +import path from 'node:path'; |
4 | 4 | import { fileURLToPath } from 'node:url';
|
5 | 5 | import { create } from 'sv';
|
6 | 6 |
|
7 | 7 | // This download the currente Vite template from Github, adjusts it to our needs, and saves it to static/svelte-template.json
|
8 | 8 | // This is used by the Svelte REPL as part of the "download project" feature
|
9 | 9 |
|
10 | 10 | 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'); |
13 | 15 |
|
14 | 16 | try {
|
15 | 17 | 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`); |
17 | 20 | process.exit(0);
|
18 | 21 | }
|
19 | 22 | } catch {
|
|
25 | 28 | const items = readdirSync(dir, { withFileTypes: true });
|
26 | 29 |
|
27 | 30 | for (const item of items) {
|
28 |
| - const full_path = join(dir, item.name); |
| 31 | + const full_path = path.join(dir, item.name); |
29 | 32 | if (item.isDirectory()) {
|
30 | 33 | files.push(...get_all_files(full_path));
|
31 | 34 | } else {
|
|
62 | 65 |
|
63 | 66 | // add CSS styles from playground to the project
|
64 | 67 | const html = readFileSync(
|
65 |
| - join(output_dir, '../../../../packages/repl/src/lib/Output/srcdoc/index.html'), |
| 68 | + path.join(output_dir, '../../../../packages/repl/src/lib/Output/srcdoc/index.html'), |
66 | 69 | { encoding: 'utf-8' }
|
67 | 70 | );
|
68 | 71 | const css = html
|
|
0 commit comments