Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Without output file, print in stdout

  • Loading branch information...
commit f095918f1e623e73f4e4a3d2dee7d8e5f451372b 1 parent 384421c
@Filirom1 Filirom1 authored
Showing with 9 additions and 22 deletions.
  1. +5 −18 bin/jst.js
  2. +4 −4 readme.md
View
23 bin/jst.js
@@ -28,7 +28,6 @@ var nopt = require("nopt")
, "verbose" : "Print logs for debug"
}
, defaults = { "inputdir" : process.cwd()
- , "output" : process.cwd()
, "watch" : false
, "namespace" : engines.defaults.namespace
, "include" : engines.defaults.include
@@ -57,7 +56,7 @@ if(!options.template){
process.exit(-1);
function showUsage(){
- var usage = 'Usage: jst [--template format: ' + allowedengine.join('|') + '] [INPUT_DIR] [OUTPUT]';
+ var usage = 'Usage: jst [--template format: ' + allowedengine.join('|') + '] [INPUT_DIR] [OUTPUT?]';
var out = {}
, getLenght = function( it ){ return it.length }
, optsLen = _(_(description).keys() ).max(getLenght).length
@@ -94,8 +93,9 @@ if(!options.template){
if(options.argv.remain && options.argv.remain.length >=1 ) options.inputdir = options.argv.remain[0];
if(options.argv.remain && options.argv.remain.length >=2 ) options.output = options.argv.remain[1];
+if(!options.output) options.stdout = true;
-if(!options.inputdir || !options.output) return optimist.showHelp();
+if(!options.inputdir) return optimist.showUsage();
if(!options.templates in engines) {
return console.error('--template ' + options.template + ' is not allowed. Use ' + allowedengine);
@@ -122,21 +122,8 @@ function write( data, callback ){
return console.log(data);
}
var output = options.output;
- fs.stat(output, function(err, stat){
- if(err){
- // do nothing
- }else if(stat.isFile()){
- // do nothing
- }else if(stat.isDirectory()){
- // if `output` is a directory, create a new file called `templates.js` in this directory.
- output = join(output, 'templates.js');
- }else{
- return engines.handleError(ouput, 'is not a file nor a directory');
- }
-
- fs.writeFile( output, data, 'utf8', function( err ){
- if( typeof callback == "function" ) callback(err, output);
- });
+ fs.writeFile( output, data, 'utf8', function( err ){
+ if( typeof callback == "function" ) callback(err, output);
});
};
View
8 readme.md
@@ -47,19 +47,19 @@ Or from sources
universal-jst comes with a command line tool.
- $ jst --template [template_engine] [path/to/templates] [path/to/output]
+ $ jst --template [template-engine] [path/to/templates] > [path/to/output]
or
- $ jst --template [template-engine] [path/to/templates] --stdout > [path/to/output]
+ $ jst --template [template_engine] [path/to/templates] [path/to/output]
Usage :
- $ jst [--template format: string|underscore|_|jquery-tmpl|handlebars|hbs|dust|hogan|mustache|mu] [INPUT_DIR] [OUTPUT]
+ $ jst [--template format: string|underscore|_|jquery-tmpl|handlebars|hbs|dust|hogan|mustache|mu] [INPUT_DIR] [OUTPUT?]
--template -t format : string|underscore|_|jquery-tmpl|handlebars|hbs|dust|hogan|mustache|mu
--inputdir -i directory containings the templates to compile $PWD
- --output -o output where templates will be compiled $PWD
+ --output -o output where templates will be compiled
--watch -w watch `inputdir` for change false
--namespace -ns object in the browser containing the templates window.JST
--include -I Glob patterns for templates files to include in `inputdir` **/*
Please sign in to comment.
Something went wrong with that request. Please try again.