1 | export function getVariables(name: string, version: string, env: string): Record<string, string> {
|
2 | return {
|
3 | NODE_ENV: env,
|
4 | BUILD_TIME: new Date().toDateString(),
|
5 | BUILD_TIME_FULL: new Date().toISOString(),
|
6 | BUILD_PCKG_VERSION: version,
|
7 | BUILD_PCKG_NAME: name,
|
8 | };
|
9 | }
|
10 |
|
11 | export function setEnvironment(variables: Record<string, string>) {
|
12 | Object.keys(variables).forEach(key => (process.env[key] = variables[key]));
|
13 | }
|
14 |
|
15 | export function getDefineVariables(variables: Record<string, string>) {
|
16 | return Object.entries(variables).reduce((obj, [name, value]) => {
|
17 | obj[`process.env.${name}`] = JSON.stringify(value);
|
18 | return obj;
|
19 | }, {});
|
20 | }
|