Don't import package.json in scripts/refresh-assets.ts, just read it (#3116)

Per #3018, the `import` causes `scripts/refresh-assets.ts` to fail on
Windows. This PR applies @SomeHats's suggestions cleanly on top of the
current `main`. Thank you @cscxj for the original report!

Describe what your pull request does. If appropriate, add GIFs or images
showing the before and after.

### Change Type

- [x] `internal` — Any other changes that don't affect the published
package
This commit is contained in:
Dan Groshev 2024-03-11 17:52:58 +00:00 committed by GitHub
parent 19a1d01b8e
commit f1b4f807d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -402,9 +402,9 @@ async function writeAssetDeclarationDTSFile() {
} }
async function copyVersionToDotCom() { async function copyVersionToDotCom() {
const packageVersion = await import(join(REPO_ROOT, 'packages', 'tldraw', 'package.json')).then( const packageJson = await readJsonIfExists(join(REPO_ROOT, 'packages', 'tldraw', 'package.json'))
(pkg) => pkg.version const packageVersion = packageJson.version
)
const file = `export const version = '${packageVersion}'` const file = `export const version = '${packageVersion}'`
await writeCodeFile( await writeCodeFile(
'scripts/refresh-assets.ts', 'scripts/refresh-assets.ts',