Rebuild if previously existing dependent not found, instead of throwing ENOENT
authorNick Downing <downing.nick@gmail.com>
Sun, 21 Oct 2018 23:57:04 +0000 (10:57 +1100)
committerNick Downing <downing.nick@gmail.com>
Sun, 21 Oct 2018 23:57:04 +0000 (10:57 +1100)
BuildCache.js

index 7640fa5..8253401 100644 (file)
@@ -34,8 +34,16 @@ BuildCache.prototype.get = async function(key, build_func) {
     result.done = (
       async () => {
         for (let i = 0; i < result.deps.length; ++i) {
-          stats = await fs_stat(result.deps[i])
-          if (stats.mtimeMs > result.time) {
+          let stats
+          try {
+            stats = await fs_stat(result.deps[i])
+          }
+          catch (err) {
+            if (err.code !== 'ENOENT') // err type???
+              throw err
+            //stats = undefined
+          }
+          if (stats === undefined || stats.mtimeMs > result.time) {
             if (this.diag)
               console.log('rebuilding', key, 'reason', result.deps[i])
             result.deps = [key]