-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopy_extends.js
More file actions
38 lines (30 loc) · 1.08 KB
/
Copy pathcopy_extends.js
File metadata and controls
38 lines (30 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import * as fs from 'fs';
import * as path from 'path';
import { parse } from 'jsonc-parser';
// Read tsconfig.json
const tsconfigPath = path.resolve('tsconfig.json');
const tsconfigContent = fs.readFileSync(tsconfigPath, 'utf-8');
const tsconfig = parse(tsconfigContent);
// Get the outDir from tsconfig.json
const outDir = path.join(tsconfig.compilerOptions.outDir, 'extends_collections');
// Define source and destination directories
const srcDir = 'extends_collections';
const destDir = path.resolve(outDir);
// Function to copy files recursively
function copyFiles(src, dest) {
if (!fs.existsSync(dest)) {
fs.mkdirSync(dest, { recursive: true });
}
const entries = fs.readdirSync(src, { withFileTypes: true });
for (const entry of entries) {
const srcPath = path.join(src, entry.name);
const destPath = path.join(dest, entry.name);
if (entry.isDirectory()) {
copyFiles(srcPath, destPath);
} else {
fs.copyFileSync(srcPath, destPath);
}
}
}
// Copy files from srcDir to destDir
copyFiles(srcDir, destDir);