Skip to content

Commit 690e22d

Browse files
committed
chore: update
1 parent 2bb4770 commit 690e22d

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

apps/nuxt-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dev": "nuxt dev",
88
"generate": "nuxt generate",
99
"preview": "nuxt preview",
10-
"postinstall": "node -e \"if (process.env.CI) { console.log('Skip nuxt prepare in CI'); process.exit(0) } require('node:child_process').execSync('nuxt prepare', { stdio: 'inherit' })\"",
10+
"postinstall": "node ../../scripts/prepare-nuxt-app.mjs",
1111
"prepare": "node ../../scripts/prepare-tw-patch.mjs",
1212
"tw-extract": "tw-patch extract"
1313
},

scripts/prepare-nuxt-app.mjs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { execFileSync } from 'node:child_process'
2+
import { existsSync } from 'node:fs'
3+
import path from 'node:path'
4+
import process from 'node:process'
5+
import { fileURLToPath } from 'node:url'
6+
7+
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
8+
9+
if (process.env.CI || process.env.TWM_SKIP_NUXT_PREPARE) {
10+
console.log('Skip nuxt prepare in CI or scripted installs')
11+
process.exit(0)
12+
}
13+
14+
const requiredArtifacts = [
15+
'packages/unplugin-tailwindcss-mangle/dist/nuxt.cjs',
16+
'packages/unplugin-tailwindcss-mangle/dist/nuxt.js',
17+
]
18+
19+
const missingArtifact = requiredArtifacts.find(file => !existsSync(path.resolve(repoRoot, file)))
20+
21+
if (missingArtifact) {
22+
console.log(`Skip nuxt prepare because ${missingArtifact} has not been built yet`)
23+
process.exit(0)
24+
}
25+
26+
execFileSync('nuxt', ['prepare'], {
27+
cwd: path.resolve(repoRoot, 'apps/nuxt-app'),
28+
stdio: 'inherit',
29+
shell: process.platform === 'win32',
30+
})

0 commit comments

Comments
 (0)