-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.ts
More file actions
53 lines (43 loc) · 1.34 KB
/
gulpfile.ts
File metadata and controls
53 lines (43 loc) · 1.34 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import * as fs from 'fs/promises';
import * as gulp from 'gulp';
import { copyDir } from './src/utils/copy-folder.util';
const ENV_ARG = '--env=';
gulp.task('copy', async (done) => {
const envArg = process.argv.find((arg) => arg.startsWith(ENV_ARG));
if (envArg) {
await fs.copyFile(
`./environments/${envArg.replace(ENV_ARG, '')}.backend.env`,
'./backend/.env',
);
await fs.copyFile(
`./environments/${envArg.replace(ENV_ARG, '')}.frontend.env`,
'./frontend/.env',
);
await fs.copyFile(
`./environments/${envArg.replace(ENV_ARG, '')}.project.env`,
'./.env',
);
done();
} else {
throw new Error(
'Define which env in the environments folder should be used. Example: --env=local',
);
}
});
gulp.task('set', gulp.series('copy'));
gulp.task('deploy', async (done) => {
try {
await fs.access('./deploy');
await fs.rm('./deploy', { force: true, recursive: true });
} catch (e) {
console.error(e);
} finally {
await fs.mkdir('./deploy');
}
await fs.mkdir('./deploy/backend');
await copyDir('./backend/node_modules', './deploy/node_modules');
await copyDir('./backend/build', './deploy/backend');
await fs.copyFile('./backend/.env', './deploy/.env');
await fs.mkdir('./deploy/webapp');
await copyDir('./frontend/build', './deploy/webapp');
});