Skip to content

Commit

Permalink
fix napi bad formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitropoulos committed Oct 9, 2024
1 parent e8ffdb8 commit b4f2700
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/turbo-repository/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"bugs": "https://github.com/vercel/turborepo/issues",
"homepage": "https://turbo.build/repo",
"scripts": {
"build": "napi build --platform -p turborepo-napi --cargo-cwd ../../ --cargo-name turborepo_napi native --js false --dts ../js/index.d.ts && mkdir -p js/dist && cp js/index.js js/dist/index.js && cp js/index.d.ts js/dist/index.d.ts",
"build:release": "napi build --release --platform -p turborepo-napi --cargo-cwd ../../ --cargo-name turborepo_napi native --js false",
"build": "bash scripts/build.sh",
"build:release": "bash scripts/build.sh release",
"package": "node scripts/publish.mjs",
"test": "node --import tsx --test __tests__/*.test.ts"
},
Expand All @@ -17,6 +17,7 @@
"@napi-rs/cli": "^2.16.3",
"execa": "^8.0.1",
"fs-extra": "^11.1.1",
"prettier": "^3.2.5",
"tsx": "^4.7.2"
},
"main": "dist/index.js",
Expand Down
25 changes: 25 additions & 0 deletions packages/turbo-repository/scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

flags="\
--platform \
-p turborepo-napi \
--cargo-cwd ../../ \
--cargo-name turborepo_napi \
native \
--js false \
"

if [ "$1" == "release" ]; then
flags+=" --release"
else
flags+=" --dts ../js/index.d.ts"
fi

node_modules/.bin/napi build $flags

# Unfortunately, when napi generates a .d.ts file, it doesn't match our formatting rules (it doesn't have semicolons).
# Since there's now way to configure this from napi itself, so we need to run prettier on it after generating it.
node_modules/.bin/prettier --write js/index.d.ts

mkdir -p js/dist
cp js/index.{js,d.ts} js/dist/
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b4f2700

Please sign in to comment.