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)
MinCSSCache.js

index cc966ce..e3cc928 100644 (file)
@@ -33,38 +33,34 @@ let clean_css = new CleanCSS({returnPromise: true})
 let fs_readFile = util.promisify(fs.readFile)
 let fs_writeFile = util.promisify(fs.writeFile)
 
-let MinCSSCache = function(diag) {
+let MinCSSCache = function(diag1, diag) {
   if (!this instanceof MinCSSCache)
-    throw Error('MinCSSCache is a constructor')
-  this.diag = diag || false
-
-  this.build_cache = new BuildCache()
+    throw new Error('MinCSSCache is a constructor')
+  BuildCache.call(this, diag)
+  this.diag1 = diag1
 }
 
-MinCSSCache.prototype.get = function(key) {
-  return /*await*/ this.build_cache.get(
+MinCSSCache.prototype = Object.create(BuildCache.prototype)
+
+MinCSSCache.prototype.build = async function(key, result) {
+  let render = await disk_build(
     key,
-    async result => {
-      let render = await disk_build(
-        key,
-        async temp_pathname => {
-          let render = await clean_css.minify(
-            await fs_readFile(key, {encoding: 'utf-8'})
-          )
-          for (let i = 0; i < render.warnings.length; ++i)
-            console.log(`clean-css warning: ${render.warnings[i]}`)
-          return /*await*/ fs_writeFile(
-            temp_pathname,
-            render.styles,
-            {encoding: 'utf-8'}
-          )
-        },
-        this.diag
+    async temp_pathname => {
+      let render = await clean_css.minify(
+        await fs_readFile(key, {encoding: 'utf-8'})
+      )
+      for (let i = 0; i < render.warnings.length; ++i)
+        console.log(`clean-css warning: ${render.warnings[i]}`)
+      return /*await*/ fs_writeFile(
+        temp_pathname,
+        render.styles,
+        {encoding: 'utf-8'}
       )
-      assert(render.deps.length === 0)
-      result.value = await fs_readFile(render.pathname)
-    }
+    },
+    this.diag1
   )
+  assert(render.deps.length === 0)
+  result.value = await fs_readFile(render.pathname)
 }
 
 module.exports = MinCSSCache