Permalink
Browse files

- moved to using catn8 for building d8.js

  • Loading branch information...
1 parent cc672b1 commit 14d658abe2a7e0f2daa19a7564a0e1f400c6ae90 @constantology committed Sep 14, 2012
View
10 .catn8
@@ -0,0 +1,10 @@
+{
+ "source" : {
+ "dir" : "./src",
+ "files" : ["utils", "fns", "format", "toDate", "vars", "expose"]
+ },
+ "target" : {
+ "dir" : "{pwd}"
+ },
+ "type" : "application/javascript"
+}
View
@@ -1,59 +0,0 @@
-// require modules
- var fs = require( 'fs' ),
- util = require( 'util' ),
- path = require( 'path' ),
- jsp = require( 'uglify-js' ).parser,
- pro = require( 'uglify-js' ).uglify,
- mkdirp = require( 'mkdirp' ),
- Templ8 = require( 'Templ8' );
-
-fs.readFile( process.argv[2] || './build.json', 'utf-8', function( err, data ) {
- if ( err ) throw err;
- processFiles( JSON.parse( data ) );
-} );
-
-function processFiles( params ) {
- Array.isArray( params.src.files ) || ( params.src.files = params.src.files.split( /,\s?|\s+/g ) );
- params.encoding || ( params.encoding = 'UTF-8' );
- params.file_err || ( params.file_err = 'break' );
- params.ext = params.ext.replace( /^\.+(.*)/, '$1' );
-
- var out_dir = path.resolve( util.format( '%s/%s', process.cwd(), params.out.dir || '.' ) ) + '/',
- out_file,
- src_dir = path.resolve( util.format( '%s/%s', process.cwd(), params.src.dir || '.' ) ) + '/',
- src = '',
- src_ast;
-
- fs.existsSync( out_dir ) || mkdirp.sync( out_dir, 0777 );
-
- params.src.files = ( src_dir + params.src.files.join( Templ8.format( '.{0}, {1}', params.ext, src_dir ) ) + '.' + params.ext ).split( ', ' );
- params.src.files.forEach( function( file ) {
- console.log( timestamp(), '- processing file: ', file );
-
- if ( !fs.existsSync( file ) ) {
- console.log( 'file: ', file, ' does not exist.' );
- switch ( params.file_err ) {
- case 'break' : console.log( timestamp(), ' - terminating build.' ); return;
- case 'continue' : break;
- }
- }
-
- src += Templ8.format( '\n{0}', fs.readFileSync( file, params.encoding ) );
- } );
-
- out_file = Templ8.format( '{0}{1}.{2}', out_dir, ( params.out.file || 'out' ), params.ext );
- console.log( timestamp(), '- writing file: ', out_file );
-
- src_ast = jsp.parse( src );
-
- fs.writeFileSync( out_file, src, params.encoding );
-// fs.writeFileSync( out_file, pro.gen_code( src_ast, { beautify : true, space_colon : true } ), params.encoding );
-
- if ( params.out.min ) {
- out_file = Templ8.format( '{0}{1}.{2}', out_dir, params.out.min, params.ext );
- console.log( timestamp(), '- writing minified file: ', out_file );
- fs.writeFileSync( out_file, pro.gen_code( pro.ast_squeeze( pro.ast_mangle( src_ast ) ) ), params.encoding );
- }
-}
-
-function timestamp() { return ( new Date() ).toISOString(); }
View
@@ -1,10 +0,0 @@
-{
- "encoding" : "UTF-8",
- "ext" : "js",
- "file_err" : "continue",
- "out" : { "dir" : "./", "file" : "d8", "min" : "d8.min" },
- "src" : {
- "dir" : "./src",
- "files" : ["_begin", "d8.utils", "d8.fns", "d8.format", "d8.toDate", "d8.vars", "d8.expose", "_end"]
- }
-}
View
7 d8.js
@@ -1,8 +1,8 @@
-
;!function( util ) {
"use strict";
util.x.cache( 'Date', function( Type ) {
+/*~ d8/src/utils.js ~*/
// utility methods
function _indexOf( o, k ) { var i = o.indexOf( k ); return i == -1 ? null : i; }
function _lc( o ) { return o.toLowerCase(); }
@@ -19,6 +19,7 @@
function pluck( a, k ) { return a.reduce( function( v, o ) { !( k in o ) || v.push( o[k] ); return v; }, [] ); }
function sum( v, i ) { return v + i; }
+/*~ d8/src/fns.js ~*/
// private methods
function _24hrTime( o, res ) { return ( o = Number( o ) ) < 12 && _lc( res.ampm ) == _lc( LOCALE.PM ) ? o += 12 : o; }
function _adjust( d, v, k ) { return d.adjust( k, v ); }
@@ -105,6 +106,7 @@
return s.splice( 4, s.length ).join( ' ' ).replace( re_tz, '$1' ).replace( re_tz_abbr, '' );
}
+/*~ d8/src/format.js ~*/
function buildTemplate( o ) {
if ( cache_format[o] ) return cache_format[o];
@@ -129,6 +131,7 @@
function tplOut( s ) { return 'out.push( \'' + s + '\' );'; }
+/*~ d8/src/toDate.js ~*/
function buildParser( o ) {
if ( cache_parse[o] ) return cache_parse[o];
var fn = {}, keys = [], i = -1, parts = o.replace( re_add_nr, NOREPLACE_RB ).replace( re_add_enr, NOREPLACE_RE ).split( re_split ),
@@ -219,6 +222,7 @@
function toDate( s, f ) { return buildParser( f )( s ); }
+/*~ d8/src/vars.js ~*/
var LOCALE = Type.locale, U,
// DAY_OFFSETS is the amount of days from the current day to the Monday of the week it belongs to
DAY_OFFSETS = [9, 1, 0, -1, -2, 4, 3], MS_DAY = 864e5, MS_WEEK = 6048e5,
@@ -343,6 +347,7 @@
re : [parser.D.re, ', ', parser.d.re, ' ', parser.M.re, ' ', parser.Y.re, ' ', parser.H.re, ':', parser.i.re, ':', parser.s.re, ' ', parser.O.re].join( '' )
};
+/*~ d8/src/expose.js ~*/
// instance methods
util.defs( Type.prototype, {
adjust : adjust, between : between, clearTime : clearTime,
View
@@ -6,14 +6,12 @@
},
"description" : "d8 is a date parsing and formatting micro-framework for modern JavaScript engines.",
"dependencies" : {
- "m8" : ">= 0.1.0"
+ "m8" : ">= 0.2.7"
},
"devDependencies" : {
- "Templ8" : ">= 0.3.0",
+ "catn8" : ">= 0.0.2",
"chai" : ">= 1.2.0",
- "mkdirp" : ">= 0.3.0",
- "mocha" : ">= 1.3.0",
- "uglify-js" : ">= 1.2.5"
+ "mocha" : ">= 1.4.2"
},
"engines" : {
"node" : ">= 0.4.x"
@@ -23,7 +21,7 @@
"type" : "MIT",
"url" : "https://raw.github.com/constantology/d8/master/LICENSE"
} ],
- "main" : "./d8.js",
+ "main" : "./d8",
"name" : "d8",
"repository" : {
"type" : "git",
@@ -32,5 +30,5 @@
"scripts" : {
"test" : "mocha -c --ignore-leaks -R spec -u tdd ./test/*.test.js"
},
- "version" : "0.3.5"
+ "version" : "0.3.6"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 14d658a

Please sign in to comment.