Skip to content

Commit 0d425e7

Browse files
committed
chore: update build process to use custom script for workspace builds
1 parent 2d3c6a4 commit 0d425e7

File tree

3 files changed

+33
-25
lines changed

3 files changed

+33
-25
lines changed

package-lock.json

Lines changed: 4 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
"packages/observables/package.json"
2525
],
2626
"scripts": {
27-
"postinstall": "npm run build:packages",
28-
"build:packages": "npm run build --workspaces --if-present",
27+
"postinstall": "node scripts/build-workspaces.js",
2928
"lint": "npm run lint:es",
3029
"lint:es": "eslint --flag unstable_native_nodejs_ts_config .",
3130
"prepare": "husky",

scripts/build-workspaces.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env node
2+
3+
import { execSync } from 'node:child_process';
4+
import { dirname, resolve } from 'node:path';
5+
import { fileURLToPath } from 'node:url';
6+
7+
const __dirname = dirname(fileURLToPath(import.meta.url));
8+
const cwd = resolve(__dirname, '..');
9+
10+
function run(cmd) {
11+
try {
12+
console.log(`👉 Running: ${cmd}`);
13+
execSync(cmd, { cwd, stdio: 'inherit' });
14+
return true;
15+
} catch (err) {
16+
console.warn(`⚠️ Failed: ${cmd}${err.message}`);
17+
return false;
18+
}
19+
}
20+
21+
// 1️⃣ zuerst mit pnpm im Filter-Mode
22+
if (!run('pnpm -F "./packages/**" run build --if-present')) {
23+
// 2️⃣ Fallback auf npm workspaces
24+
if (!run('npm run build --workspaces --if-present')) {
25+
console.error('❌ Build konnte nicht ausgeführt werden');
26+
process.exit(1);
27+
}
28+
}

0 commit comments

Comments
 (0)