Skip to content

Commit

Permalink
feat: handle --env <name> flags
Browse files Browse the repository at this point in the history
  • Loading branch information
rigor789 committed Apr 1, 2021
1 parent d8537fa commit 23fe6a3
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lib/data/prepare-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,25 @@ export class PrepareData extends ControllerDataBase {
constructor(public projectDir: string, public platform: string, data: any) {
super(projectDir, platform, data);

const env: any = {};

if (Array.isArray(data.env)) {
data.env.forEach((flag: string | object) => {
if (typeof flag === "string") {
env.env = flag;
return;
}

Object.assign(env, flag);
});
} else {
Object.assign(env, data.env);
}

this.release = data.release;
this.hmr = data.hmr || data.useHotModuleReload;
this.env = {
...data.env,
...env,
hmr: data.hmr || data.useHotModuleReload,
};
this.watch = data.watch;
Expand Down

0 comments on commit 23fe6a3

Please sign in to comment.