Skip to content

Commit

Permalink
Refactor use_cache.js
Browse files Browse the repository at this point in the history
  • Loading branch information
rstacruz committed Oct 19, 2015
1 parent b5b10c9 commit e035056
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
8 changes: 1 addition & 7 deletions index.js
Expand Up @@ -12,6 +12,7 @@ const hash = require('./lib/hash')
const eachCons = require('./lib/helpers/each_cons')
const toArray = require('./lib/helpers/to_array')
const memoize = require('./lib/memoize')
const useCache = require('./lib/helpers/use_cache')

/**
* Metalsmith middleware
Expand Down Expand Up @@ -81,13 +82,6 @@ function addCss (files, ms, done) {
buildCss({ imports: this.stylusImports }, callback)
}

function useCache (fname, callback) {
try {
callback(null, require('fs').readFileSync(join(__dirname, fname), 'utf-8'))
return true
} catch (e) {}
}

/**
* Add JavaScript
*/
Expand Down
10 changes: 10 additions & 0 deletions lib/helpers/use_cache.js
@@ -0,0 +1,10 @@
const readFileSync = require('fs').readFileSync
const join = require('path').join

module.exports = function useCache (fname, callback) {
try {
callback(null,
readFileSync(join(__dirname, '..', '..', fname), 'utf-8'))
return true
} catch (e) {}
}

0 comments on commit e035056

Please sign in to comment.