let fs_readFile = util.promisify(fs.readFile)
let fs_writeFile = util.promisify(fs.writeFile)
-let LessCSSCache = function(root, diag) {
+let LessCSSCache = function(root, diag1, diag) {
if (!this instanceof LessCSSCache)
- throw Error('LessCSSCache is a constructor')
+ throw new Error('LessCSSCache is a constructor')
+ BuildCache.call(this, diag)
+ this.diag1 = diag1
this.root = root || '.'
- this.diag = diag || false
-
- this.build_cache = new BuildCache()
}
-LessCSSCache.prototype.get = function(key) {
- return /*await*/ this.build_cache.get(
+LessCSSCache.prototype = Object.create(BuildCache.prototype)
+
+LessCSSCache.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 less.render(
- await fs_readFile(key, {encoding: 'utf-8'}),
- {
- compress: true,
- filename: key,
- pathnames: [path.posix.dirname(key)],
- rootkey: this.root
- }
- )
- await fs_writeFile(
- temp_pathname,
- render.css,
- {encoding: 'utf-8'}
- )
- return render.imports
- },
- this.diag
+ async temp_pathname => {
+ let render = await less.render(
+ await fs_readFile(key, {encoding: 'utf-8'}),
+ {
+ compress: true,
+ filename: key,
+ pathnames: [path.posix.dirname(key)],
+ rootkey: this.root
+ }
+ )
+ await fs_writeFile(
+ temp_pathname,
+ render.css,
+ {encoding: 'utf-8'}
)
- result.deps = result.deps.concat(render.deps)
- result.value = await fs_readFile(render.pathname)
- }
+ return render.imports
+ },
+ this.diag1
)
+ result.deps = result.deps.concat(render.deps)
+ result.value = await fs_readFile(render.pathname)
}
module.exports = LessCSSCache