Skip to content

Commit 6fea439

Browse files
committed
Backport impress#1266: Fix bug in live reload
Refs: metarhia/impress#1266 Closes: #177 PR-URL: #181
1 parent 5dd94d0 commit 6fea439

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/application.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,15 @@ class Application extends events.EventEmitter {
4949
}
5050

5151
async createScript(fileName) {
52-
const code = await fsp.readFile(fileName, 'utf8');
53-
const src = '\'use strict\';\ncontext => ' + code;
54-
const options = { filename: fileName, lineOffset: -1 };
5552
try {
53+
const code = await fsp.readFile(fileName, 'utf8');
54+
if (!code) return null;
55+
const src = '\'use strict\';\ncontext => ' + code;
56+
const options = { filename: fileName, lineOffset: -1 };
5657
const script = new vm.Script(src, options);
5758
return script.runInContext(this.sandbox, SCRIPT_OPTIONS);
5859
} catch (err) {
59-
this.logger.error(err.stack);
60+
if (err.code !== 'ENOENT') this.logger.error(err.stack);
6061
return null;
6162
}
6263
}
@@ -74,8 +75,7 @@ class Application extends events.EventEmitter {
7475
const data = await fsp.readFile(filePath);
7576
this.static.set(key, data);
7677
} catch (err) {
77-
this.logger.error(err.stack);
78-
if (err.code !== 'ENOENT') throw err;
78+
if (err.code !== 'ENOENT') this.logger.error(err.stack);
7979
}
8080
}
8181

0 commit comments

Comments
 (0)