-
Notifications
You must be signed in to change notification settings - Fork 0
/
copyEnv.js
45 lines (36 loc) · 1.15 KB
/
copyEnv.js
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
39
40
41
42
43
44
45
const fs = require('fs');
const path = require('path');
const rootDir = path.resolve(__dirname);
const workspacesDir = path.join(rootDir, 'packages');
const envFile = path.join(rootDir, '.env');
const excludedWorkspace = 'EntryDesignSystem';
const copyEnvFile = () => {
if (!fs.existsSync(envFile)) {
console.error('.env file not found in the root directory.');
process.exit(1);
}
fs.readdir(workspacesDir, (err, folders) => {
if (err) {
console.error('Failed to read packages directory:', err);
process.exit(1);
}
folders.forEach((folder) => {
if (folder === excludedWorkspace) {
console.log(`Skipping ${folder}`);
return;
}
const workspacePath = path.join(workspacesDir, folder);
const destEnvFile = path.join(workspacePath, '.env');
if (fs.lstatSync(workspacePath).isDirectory()) {
fs.copyFile(envFile, destEnvFile, (err) => {
if (err) {
console.error(`Failed to copy .env file to ${workspacePath}:`, err);
} else {
console.log(`.env file copied to ${workspacePath}`);
}
});
}
});
});
};
copyEnvFile();