Skip to content

Commit ce5ae6e

Browse files
committed
build(apps/prebuild-cli): use JavaScript instead of Bash commands for scripts
1 parent 1dcb85e commit ce5ae6e

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

apps/prebuild-cli/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"build-overlays": {
5454
"executor": "nx:run-commands",
5555
"options": {
56-
"command": "cp -R apps/prebuild-cli/overlays dist/apps/prebuild-cli"
56+
"command": "bun apps/prebuild-cli/scripts/copyOverlaysToDist.ts"
5757
}
5858
},
5959
"serve": {
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { findUpSync } from 'find-up';
2+
import * as fs from 'node:fs';
3+
import * as path from 'node:path';
4+
5+
function copyRecursiveSync(src, dest) {
6+
const exists = fs.existsSync(src);
7+
const stats = exists && fs.statSync(src);
8+
const isDirectory = exists && stats.isDirectory();
9+
if (isDirectory) {
10+
fs.mkdirSync(dest, { recursive: true });
11+
fs.readdirSync(src).forEach((childItemName) => {
12+
copyRecursiveSync(path.join(src, childItemName), path.join(dest, childItemName));
13+
});
14+
} else {
15+
fs.copyFileSync(src, dest);
16+
}
17+
}
18+
19+
const rootPackageJsonPath = findUpSync('package.json');
20+
if (!rootPackageJsonPath) {
21+
throw new Error('Could not find package.json');
22+
}
23+
24+
const rootDir = path.dirname(rootPackageJsonPath);
25+
const overlayDir = path.join(rootDir, 'apps/prebuild-cli/overlays');
26+
const outputDir = path.join(rootDir, 'dist/apps/prebuild-cli');
27+
28+
copyRecursiveSync(overlayDir, path.join(outputDir, 'overlays'));

0 commit comments

Comments
 (0)