|
1 |
| -import path from 'path'; |
2 | 1 | import fs from 'fs';
|
3 | 2 | import renderRulesTableContent from './render-rules.js';
|
4 | 3 | import { writeAndFormat } from './lib/write.js';
|
5 | 4 |
|
6 |
| -const __dirname = path.dirname(new URL(import.meta.url).pathname); |
| 5 | +const rootURL = new URL('../../../', import.meta.url); |
7 | 6 |
|
8 | 7 | const insertText = `\n${renderRulesTableContent(
|
9 | 8 | (name) => `https://sveltejs.github.io/eslint-plugin-svelte/rules/${name}/`
|
10 | 9 | )}\n`;
|
11 | 10 |
|
12 |
| -const readmeFilePath = path.resolve(__dirname, '../../../README.md'); |
| 11 | +const readmeFileURL = new URL('README.md', rootURL); |
13 | 12 | const newReadme = fs
|
14 |
| - .readFileSync(readmeFilePath, 'utf8') |
| 13 | + .readFileSync(readmeFileURL, 'utf8') |
15 | 14 | .replace(
|
16 | 15 | /<!--RULES_TABLE_START-->[\s\S]*<!--RULES_TABLE_END-->/u,
|
17 | 16 | `<!--RULES_TABLE_START-->${insertText.replace(/\$/g, '$$$$')}<!--RULES_TABLE_END-->`
|
18 | 17 | );
|
19 |
| -void writeAndFormat(readmeFilePath, newReadme); |
| 18 | +void writeAndFormat(readmeFileURL, newReadme); |
20 | 19 |
|
21 |
| -const docsReadmeFilePath = path.resolve(__dirname, '../../../docs/README.md'); |
| 20 | +const docsReadmeFileURL = new URL('./docs/README.md', rootURL); |
22 | 21 |
|
23 | 22 | void writeAndFormat(
|
24 |
| - docsReadmeFilePath, |
| 23 | + docsReadmeFileURL, |
25 | 24 | `---
|
26 | 25 | title: "eslint-plugin-svelte"
|
27 | 26 | ---
|
@@ -65,12 +64,12 @@ ${newReadme
|
65 | 64 | .replace(/\n{3,}/gu, '\n\n')}`
|
66 | 65 | );
|
67 | 66 |
|
68 |
| -const docsUserGuideFilePath = path.resolve(__dirname, '../../../docs/user-guide.md'); |
| 67 | +const docsUserGuideFileURL = new URL('./docs/user-guide.md', rootURL); |
69 | 68 |
|
70 |
| -const docsUserGuide = fs.readFileSync(docsUserGuideFilePath, 'utf8'); |
| 69 | +const docsUserGuide = fs.readFileSync(docsUserGuideFileURL, 'utf8'); |
71 | 70 |
|
72 | 71 | void writeAndFormat(
|
73 |
| - docsUserGuideFilePath, |
| 72 | + docsUserGuideFileURL, |
74 | 73 | docsUserGuide
|
75 | 74 | .replace(
|
76 | 75 | /<!--USAGE_GUIDE_START-->[\s\S]*<!--USAGE_GUIDE_END-->/u,
|
|
0 commit comments