Update to build_cache.git commit 1cc703b
authorNick Downing <nick@ndcode.org>
Sun, 2 Dec 2018 00:37:18 +0000 (11:37 +1100)
committerNick Downing <nick@ndcode.org>
Sun, 2 Dec 2018 00:37:18 +0000 (11:37 +1100)
MinHTMLCache.js

index 71e4735..4418a9f 100644 (file)
@@ -32,38 +32,34 @@ let util = require('util')
 let fs_readFile = util.promisify(fs.readFile)
 let fs_writeFile = util.promisify(fs.writeFile)
 
-let MinHTMLCache = function(diag) {
+let MinHTMLCache = function(diag1, diag) {
   if (!this instanceof MinHTMLCache)
-    throw Error('MinHTMLCache is a constructor')
-  this.diag = diag || false
-
-  this.build_cache = new BuildCache()
+    throw new Error('MinHTMLCache is a constructor')
+  BuildCache.call(this, diag)
+  this.diag1 = diag1
 }
 
-MinHTMLCache.prototype.get = function(key) {
-  return /*await*/ this.build_cache.get(
+MinHTMLCache.prototype = Object.create(BuildCache.prototype)
+
+MinHTMLCache.prototype.build = async function(key, result) {
+  let render = await disk_build(
     key,
-    async result => {
-      let render = await disk_build(
-        key,
-        async temp_pathname => /*await*/ fs_writeFile(
-          temp_pathname,
-          html_minifier.minify(
-            await fs_readFile(key, {encoding: 'utf-8'}),
-            {
-              collapseWhitespace: true,
-              minifyCSS: true,
-              minifyJS: true
-            }
-          ),
-          {encoding: 'utf-8'}
-        ),
-        this.diag
-      )
-      assert(render.deps.length === 0)
-      result.value = await fs_readFile(render.pathname)
-    }
+    async temp_pathname => /*await*/ fs_writeFile(
+      temp_pathname,
+      html_minifier.minify(
+        await fs_readFile(key, {encoding: 'utf-8'}),
+        {
+          collapseWhitespace: true,
+          minifyCSS: true,
+          minifyJS: true
+        }
+      ),
+      {encoding: 'utf-8'}
+    ),
+    this.diag1
   )
+  assert(render.deps.length === 0)
+  result.value = await fs_readFile(render.pathname)
 }
 
 module.exports = MinHTMLCache