2022-04-29 15:46:52 +00:00
|
|
|
#!/usr/bin/env zx
|
|
|
|
/* eslint-disable no-undef */
|
|
|
|
import 'zx/globals'
|
|
|
|
import fs from 'fs'
|
2022-08-31 12:29:32 +00:00
|
|
|
import path from 'path'
|
2022-04-29 15:46:52 +00:00
|
|
|
|
2023-05-03 04:22:10 +00:00
|
|
|
if (process.platform === 'win32') {
|
|
|
|
defaults.shell = "cmd.exe";
|
|
|
|
defaults.prefix = "";
|
|
|
|
}
|
|
|
|
|
2022-04-29 15:46:52 +00:00
|
|
|
// Build with [tsup](https://tsup.egoist.sh)
|
2022-11-16 03:49:15 +00:00
|
|
|
await $`npx tsup`
|
2022-04-29 15:46:52 +00:00
|
|
|
|
2023-05-03 04:22:10 +00:00
|
|
|
|
2022-04-29 15:46:52 +00:00
|
|
|
// Prepare package.json file
|
|
|
|
const packageJson = fs.readFileSync('package.json', 'utf8')
|
|
|
|
const glob = JSON.parse(packageJson)
|
|
|
|
Object.assign(glob, {
|
|
|
|
main: './index.js',
|
2022-07-03 13:38:09 +00:00
|
|
|
module: './index.mjs',
|
2022-04-29 15:46:52 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
fs.writeFileSync('dist/package.json', JSON.stringify(glob, null, 2))
|
2022-06-24 04:00:05 +00:00
|
|
|
|
2022-09-24 05:01:03 +00:00
|
|
|
const dest = path.join(__dirname, '/../../../src/main/frontend/tldraw-logseq.js')
|
2022-08-31 12:29:32 +00:00
|
|
|
|
2022-09-01 15:23:39 +00:00
|
|
|
if (fs.existsSync(dest)) fs.unlinkSync(dest)
|
2022-08-31 12:29:32 +00:00
|
|
|
fs.linkSync(path.join(__dirname, '/dist/index.js'), dest)
|