]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | var replace = require('replace-in-file'); |
2 | var buildDate = new Date(); | |
3 | var copyrightYear = buildDate.getFullYear(); | |
4 | const optionsNewYear = { | |
5 | files:[ | |
6 | 'src/environments/environment.ts', | |
7 | 'src/environments/environment.prod.ts' | |
8 | ], | |
9 | from: /{COPYRIGHT_YEAR}/g, | |
10 | to: copyrightYear, | |
11 | allowEmptyPaths: false, | |
12 | }; | |
13 | ||
14 | const optionsOldYear = { | |
15 | files:[ | |
16 | 'src/environments/environment.ts', | |
17 | 'src/environments/environment.prod.ts' | |
18 | ], | |
19 | from: /year: '(.*)'/g, | |
20 | to: "year: '{COPYRIGHT_YEAR}'", | |
21 | allowEmptyPaths: false, | |
22 | }; | |
23 | ||
24 | const optionsNewProd = { | |
25 | files:[ | |
26 | 'src/environments/environment.prod.ts' | |
27 | ], | |
28 | from: /'{PRODUCTION}'/g, | |
29 | to: true, | |
30 | allowEmptyPaths: false, | |
31 | }; | |
32 | ||
33 | const optionsNewDev = { | |
34 | files:[ | |
35 | 'src/environments/environment.ts' | |
36 | ], | |
37 | from: /'{PRODUCTION}'/g, | |
38 | to: false, | |
39 | allowEmptyPaths: false, | |
40 | }; | |
41 | ||
42 | const optionsOldProd = { | |
43 | files:[ | |
44 | 'src/environments/environment.prod.ts', | |
45 | 'src/environments/environment.ts' | |
46 | ], | |
47 | from: /production: (.*)/g, | |
48 | to: "production: '{PRODUCTION}',", | |
49 | allowEmptyPaths: false, | |
50 | }; | |
51 | ||
eafe8130 TL |
52 | const optionsDefaultLang = { |
53 | files: [ | |
54 | 'src/environments/environment.prod.ts', | |
55 | 'src/environments/environment.ts' | |
56 | ], | |
57 | from: /'{DEFAULT_LANG}'/g, | |
58 | to: `'${process.env.npm_package_config_locale}'`, | |
59 | allowEmptyPaths: false | |
60 | } | |
61 | ||
11fdf7f2 TL |
62 | try { |
63 | let changeOldYearFiles = replace.sync(optionsOldYear); | |
64 | let changeNewYearFiles = replace.sync(optionsNewYear); | |
65 | let changeOldProdFiles = replace.sync(optionsOldProd); | |
66 | let changeProdFiles = replace.sync(optionsNewProd); | |
67 | let changeDevFiles = replace.sync(optionsNewDev); | |
eafe8130 | 68 | let changeDefaultLangFiles = replace.sync(optionsDefaultLang); |
11fdf7f2 TL |
69 | console.log('Environment variables have been set'); |
70 | } | |
71 | catch (error) { | |
72 | console.error('Error occurred:', error); | |
73 | throw error | |
74 | } |