distribution-express
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.6.2 | ||
// Generated by CoffeeScript 1.6.3 | ||
var fs, parseFile, watchFile; | ||
@@ -12,5 +12,8 @@ | ||
* @param {String} options.map Config filename, default 'distribution.json' | ||
* @param {Boolean} options.watch Watch changes in config file, default 'false' in production environment | ||
* @param {Function} options.log Function for logging, set to 'false' to desable logging | ||
* @param {Function} options.error Function for logging errors, set to 'false' to desable logging | ||
* @param {Boolean} options.watch Watch changes in config file, | ||
* default 'false' in production environment | ||
* @param {Function} options.log Function for logging, | ||
* set to 'false' to desable logging | ||
* @param {Function} options.error Function for logging errors, | ||
* set to 'false' to desable logging | ||
* @throws {Error|SyntaxError} Error reading file or parsing content | ||
@@ -22,17 +25,16 @@ * | ||
module.exports = function(options) { | ||
var assets, _ref, _ref1, _ref2, _ref3; | ||
var assets; | ||
if (options == null) { | ||
options = {}; | ||
} | ||
if ((_ref = options.watch) == null) { | ||
if (options.watch == null) { | ||
options.watch = process.env.NODE_ENV !== 'production'; | ||
} | ||
if ((_ref1 = options.map) == null) { | ||
if (options.map == null) { | ||
options.map = 'distribution.json'; | ||
} | ||
if ((_ref2 = options.log) == null) { | ||
if (options.log == null) { | ||
options.log = console.log; | ||
} | ||
if ((_ref3 = options.error) == null) { | ||
if (options.error == null) { | ||
options.error = console.error; | ||
@@ -44,3 +46,2 @@ } | ||
var err; | ||
try { | ||
@@ -59,12 +60,17 @@ assets = parseFile(options.map); | ||
} | ||
return function(key) { | ||
var asset; | ||
asset = assets[key]; | ||
if (asset == null) { | ||
if (options.error != null) { | ||
options.error("asset '" + key + "' not found"); | ||
return { | ||
helper: function(key) { | ||
var asset; | ||
asset = assets[key]; | ||
if (asset == null) { | ||
if (options.error != null) { | ||
options.error("asset '" + key + "' not found"); | ||
} | ||
return key; | ||
} | ||
return asset; | ||
}, | ||
map: function() { | ||
return assets || {}; | ||
} | ||
return asset || ''; | ||
}; | ||
@@ -104,3 +110,2 @@ }; | ||
var timeout; | ||
timeout = null; | ||
@@ -107,0 +112,0 @@ return fs.watch(filename, function(event) { |
{ | ||
"name": "distribution-express", | ||
"description": "Asset manager", | ||
"version": "0.0.1", | ||
"description": "'Distribution' asset manager express helper", | ||
"version": "0.0.2", | ||
"author": "Eugeny Vlasenko <mahnunchik@gmail.com>", | ||
"main": "./lib/index.js", | ||
"main": "./lib/", | ||
"engines": { | ||
@@ -8,0 +8,0 @@ "node": ">= 0.8.0" |
3235
108