From d689fde1ba2d7953264b012874010238bbcdc9a9 Mon Sep 17 00:00:00 2001 From: Jasper De Moor Date: Tue, 22 May 2018 16:57:06 +0200 Subject: [PATCH] Get mtime of folder on wildcard imports (#1410) --- src/FSCache.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/FSCache.js b/src/FSCache.js index 199dc5f671d..38c842f0db4 100644 --- a/src/FSCache.js +++ b/src/FSCache.js @@ -34,7 +34,11 @@ class FSCache { // Write mtimes for each dependent file that is already compiled into this asset for (let dep of data.dependencies) { if (dep.includedInParent) { - let stats = await fs.stat(dep.name); + let depPath = dep.name; + if (depPath[depPath.length - 1] === '*') { + depPath = path.dirname(depPath); + } + let stats = await fs.stat(depPath); dep.mtime = stats.mtime.getTime(); } } @@ -47,7 +51,7 @@ class FSCache { await fs.writeFile(this.getCacheFile(filename), JSON.stringify(data)); this.invalidated.delete(filename); } catch (err) { - logger.error('Error writing to cache', err); + logger.error(`Error writing to cache: ${err.message}`); } } @@ -83,7 +87,7 @@ class FSCache { let json = await fs.readFile(cacheFile); let data = JSON.parse(json); - if (!await this.checkDepMtimes(data)) { + if (!(await this.checkDepMtimes(data))) { return null; }