From acf965a20e0f238aac6cf48649ab78fec867213b Mon Sep 17 00:00:00 2001 From: vilicvane Date: Wed, 10 Feb 2016 08:47:52 +0800 Subject: [PATCH] Refine implementation --- src/compiler/program.ts | 2 +- src/compiler/sys.ts | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index d9d23a92186..33c2da50c1a 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -623,7 +623,7 @@ namespace ts { const hash = sys.createHash(data); const mtimeBefore = sys.getModifiedTime(fileName); - if (mtimeBefore && outputFingerprints.hasOwnProperty(fileName)) { + if (mtimeBefore && hasProperty(outputFingerprints, fileName)) { const fingerprint = outputFingerprints[fileName]; // If output has not been changed, and the file has no external modification diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 3f33df61a0f..9f7903d4201 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -229,6 +229,7 @@ namespace ts { const _path = require("path"); const _os = require("os"); const _crypto = require("crypto"); + let hash: any; // average async stat takes about 30 microseconds // set chunk size to do 30 files in < 1 millisecond @@ -560,10 +561,18 @@ namespace ts { }, readDirectory, getModifiedTime(path) { - return _fs.existsSync(path) && _fs.statSync(path).mtime; + try { + return _fs.statSync(path).mtime; + } + catch (e) { + return undefined; + } }, createHash(data) { - const hash = _crypto.createHash("md5"); + if (!hash) { + hash = _crypto.createHash("md5"); + } + hash.update(data); return hash.digest("hex"); },