#! /usr/bin/env node

var _      = require("lodash")
 , Bundle  = require("../plugins/bundle")
 , config  = require("../plugins/config")
 , program = require('commander');

program
  .version('0.1.0')
  .option('-e, --external <modules>', 'external modules', "externals")
  .option('-f, --factorbundle', "use factor bundle")
  .option('-m, --minify' , 'minify scripts')
  .option('-s, --input <name>', 'input file')
  .option('-o, --outputFile <name>', 'output file')
  .option('-i, --ignore', 'ignore <modules>', "ignore", [])
  .option('-r, --required', 'required <modules>', "required", [])
  .option('-x, --separate', 'compile file list into separate bundles')
  .option('-w, --watch', 'Watch scripts')
  .option('-v, --vendors', 'Vendor Bundle')
  .parse(process.argv);



var files;
if(program.input){
  files = program.input;
} else if(program.vendors) {
  files = []
}

var options = ["external", "factorbundle", "minify", "outputFile", "required", "separate"]

options.forEach(function(op){
  if(!_.isEmpty(program[op]) || program[op]){
    config.set(op, program[op])
  }
});

files =  files || config.get("files");

if(program.separate){
  files.forEach(function(f){
    Bundle(config.get("minify"), f)
    .setOutput(f)
    .setVendors(program.vendors)
    .setFactor(config.get("factorbundle"))
    .build(program.watch)
  })
} else {
  Bundle(config.get("minify"), files)
    .setVendors(program.vendors)
    .setFactor(config.get("factorbundle"))
    .build(program.watch)
}





@@ -744,16 +744,64 @@
 undle')%0A
+  .option('-p, --production', 'Set production')%0A
   .parse
@@ -832,16 +832,17 @@
 iles;%0Aif
+ 
 (program
@@ -920,16 +920,84 @@
 = %5B%5D%0A%7D%0A%0A
+if (program.production)%7B%0A   process.env.NODE_ENV = 'production';%0A%7D%0A%0A
 var opti

add production enviroment