Skip to content

Commit

Permalink
dev: fix script argument direction
Browse files Browse the repository at this point in the history
  • Loading branch information
Myriad-Dreamin committed Dec 29, 2024
1 parent e8020d6 commit 8379f2b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/typst.node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@
"scripts": {
"artifacts": "napi artifacts",
"bench": "node -r @swc-node/register benchmark/bench.ts",
"build": "tsc && napi build --platform --release --dts-header \"/* auto-generated by NAPI-RS */ /* eslint-disable */ import type * as types from './index.js';\" --dts index-napi.d.ts --js index-napi.js --pipe \"prettier -w\"",
"build:debug": "tsc && napi build --platform --dts-header \"/* auto-generated by NAPI-RS */ /* eslint-disable */ import type * as types from './index.js';\" --dts index-napi.d.ts --js index-napi.js --pipe \"prettier -w\"",
"build": "node scripts/build.mjs --release",
"build:debug": "node scripts/build.mjs",
"format": "run-p format:prettier format:rs format:toml",
"format:prettier": "prettier . -w",
"format:toml": "taplo format",
"format:rs": "cargo fmt",
"lint": "exit 0",
"napi": "napi",
"tsc": "tsc",
"prepublish:napi": "napi prepublish -t npm",
"publish-gh:dry": "yarn prepublish:napi && npm publish --dry-run --access public",
"publish-gh:lib": "yarn prepublish:napi && npm publish --access public || exit 0",
Expand Down
33 changes: 33 additions & 0 deletions packages/typst.node/scripts/build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { spawnSync } from 'child_process';

const args = process.argv.slice(2);

const napiArgs = [
'napi',
'build',
'--platform',
'--release',
'--dts-header',
"/* auto-generated by NAPI-RS */ /* eslint-disable */ import type * as types from './index.js';",
'--dts',
'index-napi.d.ts',
'--js',
'index-napi.js',
'--pipe',
'prettier -w',
...args,
];

const YARN = process.platform === 'win32' ? 'yarn.cmd' : 'yarn';

const napi = spawnSync(YARN, napiArgs, { stdio: 'inherit' });
if (napi.error || napi.status !== 0) {
console.log('napi', napi.status, napi.error);
process.exit(napi.status);
}

const tsc = spawnSync(YARN, ['tsc'], { stdio: 'inherit' });
if (tsc.error || tsc.status !== 0) {
console.log('tsc', tsc.status, tsc.error);
process.exit(tsc.status);
}

0 comments on commit 8379f2b

Please sign in to comment.