Skip to content

Commit

Permalink
fix: conditionally run postinstall hook, closes #73
Browse files Browse the repository at this point in the history
  • Loading branch information
cloydlau committed Sep 6, 2023
1 parent 419505f commit e99ed40
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@
"nuxt.ts"
],
"scripts": {
"preinstall": "npx only-allow pnpm",
"postinstall": "npx simple-git-hooks",
"dev": "esno ./scripts/dev.mts",
"doc": "vitepress dev --open /README",
"build": "vite build",
"test-unit": "vitest run",
"coverage": "vitest run --coverage",
"release": "esno ./scripts/release.mts"
"release": "esno ./scripts/release.mts",
"preinstall": "npx only-allow pnpm",
"postinstall": "esno ./scripts/postinstall.mts"
},
"peerDependencies": {
"@vue/composition-api": ">=1",
Expand All @@ -58,7 +58,6 @@
}
},
"dependencies": {
"simple-git-hooks": "latest",
"vue-demi": "latest"
},
"devDependencies": {
Expand Down Expand Up @@ -88,6 +87,7 @@
"magicast": "latest",
"prompts": "latest",
"semver": "latest",
"simple-git-hooks": "latest",
"typescript": "latest",
"vanilla-jsoneditor": "latest",
"vite": "latest",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

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

9 changes: 9 additions & 0 deletions scripts/postinstall.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import process from 'node:process'
import spawn from 'cross-spawn'

// simple-git-hooks might not be installed when installing json-editor-vue as a dependency
if (process.env.INIT_CWD !== process.cwd()) {
process.exit()
}

spawn.sync('npx', ['simple-git-hooks'], { stdio: 'inherit' })

0 comments on commit e99ed40

Please sign in to comment.