var bundl = require('../../node-example/node_dev/bundl');

var minify = require('../../node-example/node_dev/bundl-minify');
var rename = require('../../node-example/node_dev/bundl-rename');
var wrap = require('../../node-example/node_dev/bundl-wrap');
var write = require('../../node-example/node_dev/bundl-write');

var options = {
    targetDir: 'src/dollar',
    outputDir: 'prebuilt'
};

var wrapOptions = {
    file: 'src/wrap/safe.js'
};

var lib = [

    '$.js',

    // core
    'core/*.js',

    // submodules
    'filter/*.js',
    'mutate/*.js',
    'readwrite/*.js',
    'style/*.js',
    'traverse/*.js',
    'trigger/*.js',

    // exports
    '../export/detect.js'

];

bundl.task('dollar', function (done) {
    var b = bundl({ 'dollar.js': lib }, options)
        .then(wrap(wrapOptions))
        .then(write())
        .then(minify())
        .then(rename({ 'dollar.js': 'dollar.min.js' }))
        .then(write());

    if (bundl.args.live) {
        b.server({
            port: '5555',
            rebuild: 'changed',
            watch: './'
        });

    } else {
        b.all(done);
    }
});

@@ -726,17 +726,260 @@
     var 
-b
+numDone = 0;%0A    function oneDone () %7B%0A        numDone++;%0A        if (numDone %3E= 2) %7B%0A            done();%0A        %7D%0A    %7D%0A%0A    var full = bundl(%7B 'dollar.js': lib %7D, options)%0A        .then(wrap(wrapOptions))%0A        .then(write());%0A%0A    var min
  = bundl
@@ -981,32 +981,36 @@
 bundl(%7B 'dollar.
+min.
 js': lib %7D, opti
@@ -1051,31 +1051,8 @@
 s))%0A
-        .then(write())%0A
     
@@ -1075,64 +1075,8 @@
 ())%0A
-        .then(rename(%7B 'dollar.js': 'dollar.min.js' %7D))%0A
     
@@ -1131,18 +1131,24 @@
         
+full.we
 b
-.
 server(%7B
@@ -1268,15 +1268,47 @@
     
-b
+full
 .all(
-d
+oneDone);%0A        min.all(oneD
 one)

switch build to stop using rename for webserver to watch changes unminified