handlebar-rider
Advanced tools
Comparing version 0.1.4 to 0.1.5
// handlebar rider | ||
optimist = require('optimist') | ||
handlebars = require('handlebars'); | ||
@@ -23,4 +23,4 @@ uglify = require('uglify-js'); | ||
templates_dir: 'app/handlebars/', | ||
outfile: 'public/javascript/templates.js', | ||
templates_dir: './app/handlebars/', | ||
outfile: './public/javascript/templates.js', | ||
templates: [], | ||
@@ -90,3 +90,3 @@ minify: true | ||
console.log(color.blue + '[handlebar-rider] New or removed file detected, recompiling' + color.reset); | ||
readAndCompile(); | ||
readAndCompile(rider.templates_dir); | ||
@@ -164,13 +164,14 @@ }; | ||
var readAndCompile = function(dir){ | ||
var readAndCompile = function(dir, argv){ | ||
try{ | ||
//read files in the directory | ||
readTemplatesDirectory(dir, function(err, files) { | ||
if (err) throw err; | ||
rider.templates = [] | ||
for(var f = 0; f < files.length; f++){ | ||
try { | ||
if(err) | ||
throw new Error('Directory does not exists: ' + dir) | ||
rider.templates = [] | ||
for(var f = 0; f < files.length; f++){ | ||
@@ -208,16 +209,53 @@ // determine whether or not it's a file or directory. | ||
}); | ||
} catch(e){ | ||
} catch (e){ | ||
console.log(color.red + '[handlebar-rider] ERROR! Check to be sure your directories exist. ' + color.reset + "\n" + e + "\n"); | ||
console.log('[handlebar-rider] Input directory: ' + dir); | ||
console.log('[handlebar-rider] Destination file: ' + rider.outfile + "\n"); | ||
if(rider.help) | ||
console.log(rider.help) | ||
} | ||
}); | ||
console.log(color.red + '[handlebar-rider] ERROR! Check to be sure your directories exist. ' + color.reset + e); | ||
} | ||
} | ||
} | ||
// runs the command line | ||
exports.run = function(){ | ||
// export for module use | ||
//get options specified on command line | ||
argv = optimist | ||
.usage('Compile a directory of handlebars templates into a single javascript file.\nCommand Line Usage: ') | ||
.alias('i','in') | ||
.describe('i','Specify an input templates directory') | ||
.default('i', rider.templates_dir) | ||
.alias('o','out') | ||
.describe('o','Specify an output file into which templates are compiled') | ||
.default('o', rider.outfile) | ||
.alias('r','readable') | ||
.describe('r','Make the output more readable by avoiding default minification') | ||
.default(false) | ||
.argv | ||
dir = argv.in; | ||
rider.templates_dir = dir; | ||
rider.minify = !argv.readable; | ||
rider.outfile = argv.out; | ||
rider.help = optimist.help() | ||
//compile on startup | ||
console.log(color.green + '[handlebar-rider] Compiling template directory ' + dir + ' to ' + rider.outfile + color.reset); | ||
console.log(color.yellow + '[handlebar-rider] Watching template directory ' + dir + color.reset); | ||
readAndCompile(dir, argv); | ||
} | ||
// export this function for module use | ||
exports.readAndCompile = readAndCompile | ||
exports.rider = rider | ||
exports.color = color | ||
exports.configure = function(config){ rider = config; } | ||
@@ -227,1 +265,2 @@ })() | ||
@@ -5,3 +5,3 @@ { | ||
"description" : "Watches a directory and precompiles handlebars templates", | ||
"version" : "0.1.4", | ||
"version" : "0.1.5", | ||
@@ -27,5 +27,6 @@ "repository" : { | ||
"dependencies" : { | ||
"handlebars" : "1.x", | ||
"uglify-js" : "1.1.1" | ||
"handlebars" : ">= 1.x", | ||
"uglify-js" : "1.1.1", | ||
"optimist" : ">= 0.3.4" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9981
167
3
+ Addedoptimist@>= 0.3.4
+ Addedhandlebars@4.7.8(transitive)
+ Addedminimist@0.0.101.2.8(transitive)
+ Addedneo-async@2.6.2(transitive)
+ Addedoptimist@0.6.1(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addeduglify-js@3.19.3(transitive)
+ Addedwordwrap@1.0.0(transitive)
- Removedamdefine@1.0.1(transitive)
- Removedasync@0.2.10(transitive)
- Removedhandlebars@1.3.0(transitive)
- Removedoptimist@0.3.7(transitive)
- Removedsource-map@0.1.43(transitive)
- Removeduglify-js@2.3.6(transitive)
Updatedhandlebars@>= 1.x