Skip to content

Commit 57ace77

Browse files
authored
Fix scripts on newer node versions (#1450)
1 parent d61991d commit 57ace77

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

packages/keystatic/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
"dist"
106106
],
107107
"scripts": {
108-
"setup": "ts-gql build && tsx scripts/l10n.cts && tsx scripts/build-prism.cts",
108+
"setup": "ts-gql build && tsx scripts/l10n.ts && tsx scripts/build-prism.ts",
109109
"build": "pnpm run setup && next build",
110110
"dev": "next dev",
111111
"start": "next start"

packages/keystatic/scripts/build-prism.cts renamed to packages/keystatic/scripts/build-prism.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import fs from 'fs/promises';
2+
import { fileURLToPath } from 'url';
23

34
const languages = [
45
'clike',
@@ -45,11 +46,18 @@ const languages = [
4546
const otherLanguages = (
4647
await Promise.all(
4748
languages.map(lang =>
48-
fs.readFile(require.resolve(`prismjs/components/prism-${lang}`), 'utf8')
49+
fs.readFile(
50+
fileURLToPath(
51+
import.meta.resolve(`prismjs/components/prism-${lang}`)
52+
),
53+
'utf8'
54+
)
4955
)
5056
)
5157
).join('\n\n');
52-
const prism = (await fs.readFile(require.resolve('prismjs'), 'utf8'))
58+
const prism = (
59+
await fs.readFile(fileURLToPath(import.meta.resolve('prismjs')), 'utf8')
60+
)
5361
.replace(
5462
`if (typeof module !== 'undefined' && module.exports) {
5563
\tmodule.exports = Prism;
@@ -72,7 +80,7 @@ if (typeof global !== 'undefined') {
7280
`var _self = globalThis;`
7381
);
7482
await fs.writeFile(
75-
`${__dirname}/../src/form/fields/document/DocumentEditor/prism.js`,
83+
`src/form/fields/document/DocumentEditor/prism.js`,
7684
'/* eslint-disable */\nglobalThis.Prism = { manual: true };\n' +
7785
prism +
7886
'\n' +
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fs from 'fs/promises';
22
import path from 'path';
33
import { compileString } from '@internationalized/string-compiler';
44

5-
const localesDir = path.join(__dirname, '../src/app/l10n');
5+
const localesDir = 'src/app/l10n';
66
(async () => {
77
const locales: Record<string, Record<string, string>> = {};
88
await Promise.all(

0 commit comments

Comments
 (0)