Skip to content

Commit 1ab991c

Browse files
Address HMR parsing review feedback
Agent-Logs-Url: https://github.com/NativeScript/nativescript-cli/sessions/58c98aaf-7d9e-410b-b92b-0708f4ff4655 Co-authored-by: NathanWalker <457187+NathanWalker@users.noreply.github.com>
1 parent 5b40da7 commit 1ab991c

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

lib/data/prepare-data.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import { IOptions } from "../declarations";
22
import { ControllerDataBase } from "./controller-data-base";
33
import * as _ from "lodash";
44

5+
function isTruthyBooleanValue(value: unknown): boolean {
6+
return value === true || value === "true";
7+
}
8+
59
export class PrepareData extends ControllerDataBase {
610
public release: boolean;
711
public hmr: boolean;
@@ -34,10 +38,9 @@ export class PrepareData extends ControllerDataBase {
3438
}
3539

3640
const hmr =
37-
data.hmr ||
38-
data.useHotModuleReload ||
39-
env.hmr === true ||
40-
env.hmr === "true";
41+
isTruthyBooleanValue(data.hmr) ||
42+
isTruthyBooleanValue(data.useHotModuleReload) ||
43+
isTruthyBooleanValue(env.hmr);
4144

4245
this.release = data.release;
4346
this.hmr = hmr;

lib/options.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ export class Options {
378378
}
379379

380380
private isHmrEnabled(): boolean {
381-
if (process.argv.includes("--no-hmr")) {
381+
if (this.isHmrExplicitlyDisabled()) {
382382
return false;
383383
}
384384

@@ -388,6 +388,19 @@ export class Options {
388388
);
389389
}
390390

391+
private isHmrExplicitlyDisabled(): boolean {
392+
return hideBin(process.argv).some((arg) => {
393+
if (arg !== "--no-hmr" && arg !== "--noHmr") {
394+
return (
395+
arg === "--no-hmr=true" ||
396+
arg === "--noHmr=true"
397+
);
398+
}
399+
400+
return true;
401+
});
402+
}
403+
391404
private isTruthyBooleanValue(value: unknown): boolean {
392405
return value === true || value === "true";
393406
}

0 commit comments

Comments
 (0)