diff options
| author | Adam Soltys <[email protected]> | 2012-11-07 17:46:49 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2012-11-07 17:52:50 -0800 |
| commit | 3e900e0bba211c2bbf2bb10c85a82dd9ce6943f0 (patch) | |
| tree | bb3ce237413df5fb0896a1696f7bd6f41ac248f3 /node_modules/jade/bin | |
| parent | 5a4e3ff9bf1db2db4fc5ae8d3bd7dcefc8c58e25 (diff) | |
| download | coinos-server-3e900e0bba211c2bbf2bb10c85a82dd9ce6943f0.tar.gz coinos-server-3e900e0bba211c2bbf2bb10c85a82dd9ce6943f0.zip | |
Use coffeescript
Diffstat (limited to 'node_modules/jade/bin')
| -rwxr-xr-x | node_modules/jade/bin/jade | 168 |
1 files changed, 0 insertions, 168 deletions
diff --git a/node_modules/jade/bin/jade b/node_modules/jade/bin/jade deleted file mode 100755 index 8f1c8163..00000000 --- a/node_modules/jade/bin/jade +++ /dev/null @@ -1,168 +0,0 @@ -#!/usr/bin/env node - -/** - * Module dependencies. - */ - -var fs = require('fs') - , program = require('commander') - , path = require('path') - , basename = path.basename - , dirname = path.dirname - , resolve = path.resolve - , exists = fs.existsSync || path.existsSync - , join = path.join - , mkdirp = require('mkdirp') - , jade = require('../'); - -// jade options - -var options = {}; - -// options - -program - .version(jade.version) - .usage('[options] [dir|file ...]') - .option('-o, --obj <str>', 'javascript options object') - .option('-O, --out <dir>', 'output the compiled html to <dir>') - .option('-p, --path <path>', 'filename used to resolve includes') - .option('-P, --pretty', 'compile pretty html output') - .option('-c, --client', 'compile function for client-side runtime.js') - .option('-D, --no-debug', 'compile without debugging (smaller functions)') - .option('-w, --watch', 'watch files for changes and automatically re-render') - -program.on('--help', function(){ - console.log(' Examples:'); - console.log(''); - console.log(' # translate jade the templates dir'); - console.log(' $ jade templates'); - console.log(''); - console.log(' # create {foo,bar}.html'); - console.log(' $ jade {foo,bar}.jade'); - console.log(''); - console.log(' # jade over stdio'); - console.log(' $ jade < my.jade > my.html'); - console.log(''); - console.log(' # jade over stdio'); - console.log(' $ echo "h1 Jade!" | jade'); - console.log(''); - console.log(' # foo, bar dirs rendering to /tmp'); - console.log(' $ jade foo bar --out /tmp '); - console.log(''); -}); - -program.parse(process.argv); - -// options given, parse them - -if (program.obj) { - if (exists(program.obj)) { - options = JSON.parse(fs.readFileSync(program.obj)); - } else { - options = eval('(' + program.obj + ')'); - } -} - -// --filename - -if (program.path) options.filename = program.path; - -// --no-debug - -options.compileDebug = program.debug; - -// --client - -options.client = program.client; - -// --pretty - -options.pretty = program.pretty; - -// --watch - -options.watch = program.watch; - -// left-over args are file paths - -var files = program.args; - -// compile files - -if (files.length) { - console.log(); - files.forEach(renderFile); - if (options.watch) { - files.forEach(function (file) { - fs.watchFile(file, {interval: 100}, function (curr, prev) { - if (curr.mtime > prev.mtime) renderFile(file); - }); - }); - } - process.on('exit', function () { - console.log(); - }); -// stdio -} else { - stdin(); -} - -/** - * Compile from stdin. - */ - -function stdin() { - var buf = ''; - process.stdin.setEncoding('utf8'); - process.stdin.on('data', function(chunk){ buf += chunk; }); - process.stdin.on('end', function(){ - var fn = jade.compile(buf, options); - var output = options.client - ? fn.toString() - : fn(options); - process.stdout.write(output); - }).resume(); -} - -/** - * Process the given path, compiling the jade files found. - * Always walk the subdirectories. - */ - -function renderFile(path) { - var re = /\.jade$/; - fs.lstat(path, function(err, stat) { - if (err) throw err; - // Found jade file - if (stat.isFile() && re.test(path)) { - fs.readFile(path, 'utf8', function(err, str){ - if (err) throw err; - options.filename = path; - var fn = jade.compile(str, options); - var extname = options.client ? '.js' : '.html'; - path = path.replace(re, extname); - if (program.out) path = join(program.out, basename(path)); - var dir = resolve(dirname(path)); - mkdirp(dir, 0755, function(err){ - if (err) throw err; - var output = options.client - ? fn.toString() - : fn(options); - fs.writeFile(path, output, function(err){ - if (err) throw err; - console.log(' \033[90mrendered \033[36m%s\033[0m', path); - }); - }); - }); - // Found directory - } else if (stat.isDirectory()) { - fs.readdir(path, function(err, files) { - if (err) throw err; - files.map(function(filename) { - return path + '/' + filename; - }).forEach(renderFile); - }); - } - }); -} |
