build.mjs 726 B

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/env zx
  2. /* eslint-disable no-undef */
  3. import 'zx/globals'
  4. import fs from 'fs'
  5. import path from 'path'
  6. if (process.platform === 'win32') {
  7. defaults.shell = "cmd.exe";
  8. defaults.prefix = "";
  9. }
  10. // Build with [tsup](https://tsup.egoist.sh)
  11. await $`npx tsup`
  12. // Prepare package.json file
  13. const packageJson = fs.readFileSync('package.json', 'utf8')
  14. const glob = JSON.parse(packageJson)
  15. Object.assign(glob, {
  16. main: './index.js',
  17. module: './index.mjs',
  18. })
  19. fs.writeFileSync('dist/package.json', JSON.stringify(glob, null, 2))
  20. const dest = path.join(__dirname, '/../../../src/main/frontend/tldraw-logseq.js')
  21. if (fs.existsSync(dest)) fs.unlinkSync(dest)
  22. fs.linkSync(path.join(__dirname, '/dist/index.js'), dest)