Permalink
Browse files

testing

  • Loading branch information...
Max Melentiev
Max Melentiev committed Jan 11, 2013
1 parent b3276af commit 2e9565ea07cfd1f1800cb10aa3bf26bf06498bdc
Showing with 1,051 additions and 966 deletions.
  1. +29 −0 Cakefile
  2. +14 −0 bin/dot-compile
  3. +0 −79 compile-doT.js
  4. +0 −76 compile-flow.coffee
  5. +0 −100 compile-flow.js
  6. +0 −72 compile.coffee
  7. +0 −87 compile.js
  8. +0 −233 doT.coffee
  9. +308 −256 doT.js
  10. +257 −0 doT.js.orig
  11. +1 −7 doT.min.js
  12. +0 −56 doU.js
  13. +81 −0 dot-compile.js
  14. +22 −0 dot-express.js
  15. +34 −0 package.json
  16. +231 −0 src/doT.coffee
  17. +61 −0 src/dot-compile.coffee
  18. +13 −0 src/dot-express.coffee
View
@@ -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)
View
@@ -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)
+})
View
@@ -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()
- } )
-}
View
@@ -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()
-)
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -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

Please sign in to comment.