Permalink
Please sign in to comment.
Showing
with
1,051 additions
and 966 deletions.
- +29 −0 Cakefile
- +14 −0 bin/dot-compile
- +0 −79 compile-doT.js
- +0 −76 compile-flow.coffee
- +0 −100 compile-flow.js
- +0 −72 compile.coffee
- +0 −87 compile.js
- +0 −233 doT.coffee
- +308 −256 doT.js
- +257 −0 doT.js.orig
- +1 −7 doT.min.js
- +0 −56 doU.js
- +81 −0 dot-compile.js
- +22 −0 dot-express.js
- +34 −0 package.json
- +231 −0 src/doT.coffee
- +61 −0 src/dot-compile.coffee
- +13 −0 src/dot-express.coffee
@@ -0,0 +1,29 @@ | ||
+#! ./node_modules/.bin/cake run | ||
+ | ||
+{spawn, exec} = require 'child_process' | ||
+ | ||
+BIN = "#{__dirname}/node_modules/.bin/" | ||
+ | ||
+all = -> | ||
+ uglify() | ||
+ | ||
+uglify = -> | ||
+ compile() | ||
+ cmd = "#{BIN}uglifyjs -o #{__dirname}/doT.min.js #{__dirname}/doT.js" | ||
+ console.log(cmd) | ||
+ exec(cmd) | ||
+ | ||
+compile = -> | ||
+ cmd = "#{BIN}coffee -c -o #{__dirname} #{__dirname}/src" | ||
+ console.log(cmd) | ||
+ exec(cmd) | ||
+ | ||
+clean = -> | ||
+ cmd = "rm #{__dirname}/*.js" | ||
+ console.log(cmd) | ||
+ exec(cmd) | ||
+ | ||
+task('all', 'Build tasks', all) | ||
+task('uglify', 'Uglify scripts', uglify) | ||
+task('compile', 'Compile coffeescript', compile) | ||
+task('clean', 'Clean from compiled js', clean) |
@@ -0,0 +1,14 @@ | ||
+#!/usr/bin/env js | ||
+var argv = require('optimist').default({ | ||
+ base: '' | ||
+}).alias({ | ||
+ base: 'b' | ||
+}).argv | ||
+argv.files = argv._ | ||
+ | ||
+require(__dirname + '/../dot-compile')(argv, function(err, data){ | ||
+ if (err) | ||
+ process.stderr.write(err) | ||
+ else | ||
+ process.stdout.write(data) | ||
+}) |
@@ -1,79 +0,0 @@ | ||
-#!/usr/bin/env js | ||
- | ||
-var fs = require( 'fs' ) | ||
-var path = require( 'path' ) | ||
-var argv = require( 'optimist' ) | ||
- .default({ base: '' }) | ||
- .alias({ base: 'b' }) | ||
- .argv | ||
- | ||
-//var doT = require( 'doT' ) | ||
-var DIR = path.dirname( path.dirname( process.argv[1] ) ) | ||
-var doT = require( DIR + '/misc/js/doT.js' ) | ||
- | ||
-var asyncCalls = 0 | ||
- | ||
-argv._.forEach( function( val, i ) { readItem( val ) } ) | ||
-function asyncAfterAll() { process.stdout.write( doT.exportCached() ) } | ||
- | ||
-function asyncStarted() { asyncCalls += 1 } | ||
-function asyncDone() | ||
-{ | ||
- asyncCalls -= 1 | ||
- if ( 0 == asyncCalls ) | ||
- asyncAfterAll() | ||
-} | ||
- | ||
-function readItem( item ) | ||
-{ | ||
- asyncStarted() | ||
- fs.stat( item, function( err, stat ) { | ||
- if ( err ) | ||
- { | ||
- process.stderr.write( err ) | ||
- } else if ( stat.isDirectory() ) | ||
- { | ||
- asyncStarted() | ||
- fs.readdir( item, function( err, files ) { | ||
- if ( err ) | ||
- process.stderr.write( err ) | ||
- else | ||
- files.forEach( function( file ){ readItem( path.join( item, file ) ) } ) | ||
- asyncDone() | ||
- } ) | ||
- } else | ||
- { | ||
- readFile( item ) | ||
- } | ||
- asyncDone() | ||
- } ) | ||
-} | ||
- | ||
-function readFile( file ) | ||
-{ | ||
- asyncStarted() | ||
- fs.readFile( file, function( err, data ) | ||
- { | ||
- if ( err ) | ||
- { | ||
- process.stderr.write( 'Error reading file "' + file + '": ' + err + '\n' ) | ||
- } else | ||
- { | ||
- var id = path.basename( file, path.extname( file ) ) | ||
- if ( argv.base ) | ||
- { | ||
- var rel = path.relative( argv.base, path.dirname( file ) ).replace( /\//g, '.' ) | ||
- rel && ( id = rel + '.' + id ) | ||
- } | ||
- try | ||
- { | ||
- var f = doT.compile( data ); | ||
- doT.addCached( id, f ) | ||
- } catch( err ) | ||
- { | ||
- process.stderr.write( 'Error compiling file "' + file + '": ' + err + '\n' ) | ||
- } | ||
- } | ||
- asyncDone() | ||
- } ) | ||
-} |
@@ -1,76 +0,0 @@ | ||
-#!/usr/bin/env js | ||
- | ||
-fs = require 'fs' | ||
-path = require 'path' | ||
-flow = require 'flow' | ||
-doT = require './doT.js' | ||
-#DIR = path.dirname path.dirname process.argv[1] | ||
-#doT = require DIR + '/misc/js/doT.js' | ||
- | ||
-asyncCalls = 0 | ||
-asyncStarted = () -> asyncCalls += 1 | ||
-asyncDone = () -> | ||
- asyncCalls -= 1 | ||
- asyncAfterAll() if 0 == asyncCalls | ||
- | ||
-readItem = ( item, callback ) -> | ||
- flow.exec( | ||
- -> | ||
- fs.stat item, @ | ||
- ( err, stat ) -> | ||
- if err | ||
- process.stderr.write err | ||
- @(err) | ||
- else if stat.isDirectory() | ||
- cb = @ | ||
- flow.exec( | ||
- -> | ||
- fs.readdir item, @ | ||
- ( err, files ) -> | ||
- if err | ||
- process.stderr.write err | ||
- @(err) | ||
- else | ||
- files.forEach ( file ) => readItem path.join( item, file ), @MULTI() | ||
- -> cb(null) | ||
- ) | ||
- else | ||
- readFile item, @ | ||
- -> callback(null) | ||
- ) | ||
- | ||
-readFile = ( file, callback ) -> | ||
- flow.exec( | ||
- -> | ||
- fs.readFile file, @ | ||
- ( err, data ) -> | ||
- if err | ||
- process.stderr.write "Error reading file '#{file}': '#{err}\n" | ||
- @(e) | ||
- else | ||
- id = path.basename file, path.extname file | ||
- if argv.base | ||
- rel = path.relative( argv.base, path.dirname file) | ||
- .replace /\//g, '.' | ||
- id = "#{rel}.#{id}" if rel | ||
- try | ||
- f = doT.compile data | ||
- doT.addCached id, f | ||
- @(null, f) | ||
- catch e | ||
- process.stderr.write "Error compiling file '#{file}': '#{e}'\n" | ||
- @(e) | ||
- -> callback(null) | ||
- ) | ||
- | ||
-argv = require( 'optimist' ) | ||
- .default( base: '' ) | ||
- .alias( base: 'b' ) | ||
- .argv | ||
- | ||
-flow.exec( | ||
- -> | ||
- argv._.forEach ( val, i ) => readItem val, @MULTI() | ||
- -> | ||
- process.stdout.write doT.exportCached() | ||
-) |
@@ -1,72 +0,0 @@ | ||
-#!/usr/bin/env js | ||
- | ||
-fs = require 'fs' | ||
-path = require 'path' | ||
-doT = require './doT.js' | ||
-#DIR = path.dirname path.dirname process.argv[1] | ||
-#doT = require DIR + '/misc/js/doT.js' | ||
- | ||
-asyncCalls = 0 | ||
-asyncStarted = () -> asyncCalls += 1 | ||
-asyncDone = () -> | ||
- asyncCalls -= 1 | ||
- asyncAfterAll() if 0 == asyncCalls | ||
- | ||
-readItem = ( item, callback ) -> | ||
- flow.exec( | ||
- -> | ||
- fs.stat item, @ | ||
- ( err, stat ) -> | ||
- if err | ||
- process.stderr.write err | ||
- @() | ||
- else if stat.isDirectory() | ||
- flow.exec( | ||
- -> | ||
- fs.readdir item, @ | ||
- ( err, files ) -> | ||
- if err | ||
- process.stderr.write err | ||
- @() | ||
- else | ||
- files.forEach ( file ) -> readItem path.join( item, file ), @.MULTI() | ||
- -> @() | ||
- ) | ||
- else | ||
- readFile item, @ | ||
- -> callback() | ||
- ) | ||
- | ||
-readFile = ( file, callback ) -> | ||
- flow.exec( | ||
- -> | ||
- fs.readFile file, @ | ||
- ( err, data ) -> | ||
- if err | ||
- process.stderr.write "Error reading file '#{file}': '#{err}\n" | ||
- else | ||
- id = path.basename file, path.extname file | ||
- if argv.base | ||
- rel = path.relative( argv.base, path.dirname file) | ||
- .replace /\//g, '.' | ||
- id = "#{rel}.#{id}" if rel | ||
- try | ||
- f = doT.compile data | ||
- doT.addCached id, f | ||
- catch err | ||
- process.stderr.write "Error compiling file '#{file}': '#{err}'\n" | ||
- @() | ||
- -> callback() | ||
- ) | ||
- | ||
-argv = require( 'optimist' ) | ||
- .default( base: '' ) | ||
- .alias( base: 'b' ) | ||
- .argv | ||
- | ||
-flow.exec( | ||
- -> | ||
- argv._.forEach ( val, i ) -> readItem val, this.MULTI() | ||
- -> | ||
- process.stdout.write doT.exportCached() | ||
-) |

Oops, something went wrong.
0 comments on commit
2e9565e