Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit 55bf04d

Browse files
author
Dimitar Tachev
authored
Merge pull request #1020 from NativeScript/vladimirov/hmr-fail-ios
fix(hmr): check for hot update should not create new file
2 parents 87f5ca7 + 20cbf18 commit 55bf04d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

hmr/hmr-update.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import * as hot from "../hot";
2-
import { knownFolders } from "tns-core-modules/file-system";
2+
import { knownFolders, path, File } from "tns-core-modules/file-system";
33

44
declare const __webpack_require__: any;
55

66
export function hmrUpdate() {
7-
const applicationFiles = knownFolders.currentApp();
7+
const currentAppFolder = knownFolders.currentApp();
88
const latestHash = __webpack_require__["h"]();
9-
return hot(latestHash, filename => applicationFiles.getFile(filename));
9+
return hot(latestHash, filename => {
10+
const fullFilePath = path.join(currentAppFolder.path, filename);
11+
return File.exists(fullFilePath) ? currentAppFolder.getFile(filename) : null;
12+
});
1013
}

hot.js

+4
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ function update(latestHash, options) {
147147

148148
function getNextHash(hash, getFileContent) {
149149
const file = getFileContent(`${hash}.hot-update.json`);
150+
if (!file) {
151+
return Promise.resolve(hash);
152+
}
153+
150154
return file.readText().then(hotUpdateContent => {
151155
if (hotUpdateContent) {
152156
const manifest = JSON.parse(hotUpdateContent);

0 commit comments

Comments
 (0)