From aa1511d95c24039f197bf755abdb9ca3447621bb Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 13 Mar 2014 14:24:51 -0300 Subject: [PATCH 01/22] modularize browser build.js --- browser/build.js | 136 +++++++++++++++++++++++++++-------------------- 1 file changed, 78 insertions(+), 58 deletions(-) diff --git a/browser/build.js b/browser/build.js index 4deae00..cf94cdf 100644 --- a/browser/build.js +++ b/browser/build.js @@ -1,18 +1,8 @@ 'use strict'; -/* - * - * The key parameter 'pack' - * The supplied 'custom_prelude.js' file is needed for - * .load function of soop. - */ - var fs = require('fs'); var browserify = require('browserify'); var browserPack = require('browser-pack'); -var program = require('commander'); - -// concat browser vendor files var exec = require('child_process').exec; var sys = require('sys'); var puts = function(error, stdout, stderr) { @@ -21,26 +11,8 @@ var puts = function(error, stdout, stderr) { sys.puts(stderr); }; -exec('cd browser; sh concat.sh', puts); - -var list = function(val) { - return val.split(','); -}; - -program - .version('0.0.1') - .option('-a, --includeall', 'Include all submodules.') - .option('-d, --dontminify', 'Don\'t minify the code.') - .option('-s, --submodules ', 'Include the listed comma-separated submodules.', list) - .parse(process.argv); - -if (!program.includeall && (!program.submodules || program.submodules.length === 0)) { - console.log('Must use either -s or -a option. For more info use the --help option'); - process.exit(1); -} - -var pack = function (params) { - var preludePath = 'node_modules/soop/example/custom_prelude.js'; +var pack = function(params) { + var preludePath = 'node_modules/soop/example/custom_prelude.js'; params.raw = true; params.sourceMapPrefix = '//#'; params.prelude = fs.readFileSync(preludePath, 'utf8'); @@ -80,40 +52,88 @@ var modules = [ 'util/VersionedData', ]; -var opts = {}; -opts.pack = pack; -opts.debug = true; -opts.standalone = 'bitcore'; -opts.insertGlobals = true; - -var b = browserify(opts); -b.require('browserify-bignum/bignumber.js', {expose: 'bignum'} ); -b.require('browserify-buffertools/buffertools.js', {expose:'buffertools'}); -b.require('base58-native', {expose: 'base58-native'}); -b.require('./bitcore', {expose: 'bitcore'}); -modules.forEach(function(m) { - if (program.includeall || program.submodules.indexOf(m) > -1) { - console.log('Including '+m+' in the browser bundle'); - b.require('./' + m + '.js' , {expose: './'+m} ); +var createBitcore = function(opts) { + + // concat browser vendor files + exec('cd browser; sh concat.sh', puts); + + if (!opts.includeall && (!opts.submodules || opts.submodules.length === 0)) { + console.log('Must use either -s or -a option. For more info use the --help option'); + process.exit(1); } -}); -if (!program.dontminify) { - b.transform({ - global: true - }, 'uglifyify'); -} + var bopts = { + pack : pack, + debug : true, + standalone : 'bitcore', + insertGlobals: true + }; + var b = browserify(bopts); + + b.require('browserify-bignum/bignumber.js', { + expose: 'bignum' + }); + b.require('browserify-buffertools/buffertools.js', { + expose: 'buffertools' + }); + b.require('base58-native', { + expose: 'base58-native' + }); + b.require('./bitcore', { + expose: 'bitcore' + }); + modules.forEach(function(m) { + if (opts.includeall || opts.submodules.indexOf(m) > -1) { + console.log('Including ' + m + ' in the browser bundle'); + b.require('./' + m + '.js', { + expose: './' + m + }); + } + }); + + if (!opts.dontminify) { + b.transform({ + global: true + }, 'uglifyify'); + } -var bundle = b.bundle(); -bundle = bundle.pipe(fs.createWriteStream('browser/bundle.js')); + var bundle = b.bundle(); + return bundle; +}; -opts.standalone = 'testdata'; -var tb = browserify(opts); -tb.require('./test/testdata', {expose: 'testdata'}); -tb.transform('brfs'); +var createTestData = function() { + var bopts = { + pack : pack, + debug : true, + standalone : 'testdata', + insertGlobals: true + }; + var tb = browserify(bopts); + tb.require('./test/testdata', { + expose: 'testdata' + }); + tb.transform('brfs'); + + return tb.bundle(); +}; -tb.bundle().pipe(fs.createWriteStream('browser/testdata.js')); +if (require.main === module) { + var list = function(val) { + return val.split(','); + }; + var program = require('commander'); + program + .version('0.0.1') + .option('-a, --includeall', 'Include all submodules.') + .option('-d, --dontminify', 'Don\'t minify the code.') + .option('-s, --submodules ', 'Include the listed comma-separated submodules.', list) + .parse(process.argv); + var bitcoreBundle = createBitcore(program); + var testBundle = createTestData(program); + testBundle.pipe(fs.createWriteStream('browser/testdata.js')); + bitcoreBundle.pipe(fs.createWriteStream('browser/bundle.js')); +} From ee04af636252f45a61ed6ecadd7f4eb14554ee4f Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 13 Mar 2014 15:06:13 -0300 Subject: [PATCH 02/22] check submodule validity --- browser/build.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/browser/build.js b/browser/build.js index cf94cdf..bf24609 100644 --- a/browser/build.js +++ b/browser/build.js @@ -61,6 +61,13 @@ var createBitcore = function(opts) { console.log('Must use either -s or -a option. For more info use the --help option'); process.exit(1); } + + if (opts.submodules) { + for (var i = 0; i Date: Thu, 13 Mar 2014 15:28:14 -0300 Subject: [PATCH 03/22] add exports --- browser/build.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/browser/build.js b/browser/build.js index bf24609..46efebc 100644 --- a/browser/build.js +++ b/browser/build.js @@ -142,5 +142,7 @@ if (require.main === module) { testBundle.pipe(fs.createWriteStream('browser/testdata.js')); bitcoreBundle.pipe(fs.createWriteStream('browser/bundle.js')); - } + +module.exports.createBitcore = createBitcore; +module.exports.createTestData = createTestData; From 25868dc8f0731ad8407908ee64e464d23f1d4d92 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 13 Mar 2014 16:05:04 -0300 Subject: [PATCH 04/22] add dir option --- browser/build.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/browser/build.js b/browser/build.js index 46efebc..0513610 100644 --- a/browser/build.js +++ b/browser/build.js @@ -54,8 +54,11 @@ var modules = [ var createBitcore = function(opts) { + + opts.dir = opts.dir || ''; + // concat browser vendor files - exec('cd browser; sh concat.sh', puts); + exec('cd '+opts.dir+'browser; sh concat.sh', puts); if (!opts.includeall && (!opts.submodules || opts.submodules.length === 0)) { console.log('Must use either -s or -a option. For more info use the --help option'); From f1834162dd3135ea36ef1ba7c4a2ed4f8843e2d7 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 13 Mar 2014 16:33:46 -0300 Subject: [PATCH 05/22] fix paths --- browser/build.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/browser/build.js b/browser/build.js index 0513610..28095a8 100644 --- a/browser/build.js +++ b/browser/build.js @@ -89,13 +89,13 @@ var createBitcore = function(opts) { b.require('base58-native', { expose: 'base58-native' }); - b.require('./bitcore', { + b.require('./'+ opts.dir +'bitcore', { expose: 'bitcore' }); modules.forEach(function(m) { if (opts.includeall || opts.submodules.indexOf(m) > -1) { console.log('Including ' + m + ' in the browser bundle'); - b.require('./' + m + '.js', { + b.require('./' + opts.dir + m + '.js', { expose: './' + m }); } From 5db6dfd8ede43dc93fa7eef3cc04b2ca8bf4b6c3 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 13 Mar 2014 16:45:10 -0300 Subject: [PATCH 06/22] fix paths --- browser/build.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/browser/build.js b/browser/build.js index 28095a8..a85049b 100644 --- a/browser/build.js +++ b/browser/build.js @@ -80,13 +80,13 @@ var createBitcore = function(opts) { }; var b = browserify(bopts); - b.require('browserify-bignum/bignumber.js', { + b.require(opts.dir + 'browserify-bignum/bignumber.js', { expose: 'bignum' }); - b.require('browserify-buffertools/buffertools.js', { + b.require(opts.dir + 'browserify-buffertools/buffertools.js', { expose: 'buffertools' }); - b.require('base58-native', { + b.require(opts.dir + 'base58-native', { expose: 'base58-native' }); b.require('./'+ opts.dir +'bitcore', { From 435604cf4903f311c3e2c970a142ed8b5e7e2867 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 13 Mar 2014 18:54:48 -0300 Subject: [PATCH 07/22] make stdout output possible --- browser/build.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/browser/build.js b/browser/build.js index a85049b..b9604c8 100644 --- a/browser/build.js +++ b/browser/build.js @@ -58,24 +58,24 @@ var createBitcore = function(opts) { opts.dir = opts.dir || ''; // concat browser vendor files - exec('cd '+opts.dir+'browser; sh concat.sh', puts); + exec('cd ' + opts.dir + 'browser; sh concat.sh', puts); if (!opts.includeall && (!opts.submodules || opts.submodules.length === 0)) { console.log('Must use either -s or -a option. For more info use the --help option'); process.exit(1); } - + if (opts.submodules) { - for (var i = 0; i', 'Include the listed comma-separated submodules.', list) .parse(process.argv); var bitcoreBundle = createBitcore(program); var testBundle = createTestData(program); testBundle.pipe(fs.createWriteStream('browser/testdata.js')); - bitcoreBundle.pipe(fs.createWriteStream('browser/bundle.js')); + bitcoreBundle.pipe(program.stdout ? process.stdout : fs.createWriteStream('browser/bundle.js')); } module.exports.createBitcore = createBitcore; From 1cda79fd9391df607f123f4984b8db935dcf92ee Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 13 Mar 2014 19:10:28 -0300 Subject: [PATCH 08/22] remove extra prints --- browser/build.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/browser/build.js b/browser/build.js index b9604c8..33100a4 100644 --- a/browser/build.js +++ b/browser/build.js @@ -7,8 +7,8 @@ var exec = require('child_process').exec; var sys = require('sys'); var puts = function(error, stdout, stderr) { if (error) console.log(error); - sys.puts(stdout); - sys.puts(stderr); + //sys.puts(stdout); + //sys.puts(stderr); }; var pack = function(params) { @@ -61,7 +61,7 @@ var createBitcore = function(opts) { exec('cd ' + opts.dir + 'browser; sh concat.sh', puts); if (!opts.includeall && (!opts.submodules || opts.submodules.length === 0)) { - console.log('Must use either -s or -a option. For more info use the --help option'); + if (!opts.stdout) console.log('Must use either -s or -a option. For more info use the --help option'); process.exit(1); } @@ -94,7 +94,7 @@ var createBitcore = function(opts) { }); modules.forEach(function(m) { if (opts.includeall || opts.submodules.indexOf(m) > -1) { - console.log('Including ' + m + ' in the browser bundle'); + if (!opts.stdout) console.log('Including ' + m + ' in the browser bundle'); b.require('./' + opts.dir + m + '.js', { expose: './' + m }); From cd88011875d127394d899b715ac0256ca93e754b Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 13 Mar 2014 19:21:15 -0300 Subject: [PATCH 09/22] muting testdata for stdout --- browser/build.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/browser/build.js b/browser/build.js index 33100a4..64dbaf1 100644 --- a/browser/build.js +++ b/browser/build.js @@ -141,10 +141,11 @@ if (require.main === module) { .option('-o, --stdout', 'Specify output as stdout') .option('-s, --submodules ', 'Include the listed comma-separated submodules.', list) .parse(process.argv); + if (!program.stdout) { + var testBundle = createTestData(program); + testBundle.pipe(fs.createWriteStream('browser/testdata.js')); + } var bitcoreBundle = createBitcore(program); - var testBundle = createTestData(program); - - testBundle.pipe(fs.createWriteStream('browser/testdata.js')); bitcoreBundle.pipe(program.stdout ? process.stdout : fs.createWriteStream('browser/bundle.js')); } From b3e243e397e3af946a04ac7e8563a1973bc12299 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 13 Mar 2014 19:23:04 -0300 Subject: [PATCH 10/22] base dir --- browser/build.js | 1 + 1 file changed, 1 insertion(+) diff --git a/browser/build.js b/browser/build.js index 64dbaf1..3e5ae39 100644 --- a/browser/build.js +++ b/browser/build.js @@ -139,6 +139,7 @@ if (require.main === module) { .option('-a, --includeall', 'Include all submodules.') .option('-d, --dontminify', 'Don\'t minify the code.') .option('-o, --stdout', 'Specify output as stdout') + .option('-D, --dir', 'Specify a base directory') .option('-s, --submodules ', 'Include the listed comma-separated submodules.', list) .parse(process.argv); if (!program.stdout) { From 0e9ec8b57c123025b9861bf58624860c31f9037f Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 13 Mar 2014 19:55:26 -0300 Subject: [PATCH 11/22] fix dir --- browser/build.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser/build.js b/browser/build.js index 3e5ae39..6049e01 100644 --- a/browser/build.js +++ b/browser/build.js @@ -139,7 +139,7 @@ if (require.main === module) { .option('-a, --includeall', 'Include all submodules.') .option('-d, --dontminify', 'Don\'t minify the code.') .option('-o, --stdout', 'Specify output as stdout') - .option('-D, --dir', 'Specify a base directory') + .option('-D, --dir ', 'Specify a base directory') .option('-s, --submodules ', 'Include the listed comma-separated submodules.', list) .parse(process.argv); if (!program.stdout) { From dabfbc0cf3a5cf4437d42ff7a28a03c4a658ce7a Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 13 Mar 2014 14:24:51 -0300 Subject: [PATCH 12/22] modularize browser build.js --- browser/build.js | 132 +++++++++++++++++++++++++++-------------------- 1 file changed, 76 insertions(+), 56 deletions(-) diff --git a/browser/build.js b/browser/build.js index ca91ca6..56f2116 100644 --- a/browser/build.js +++ b/browser/build.js @@ -1,18 +1,8 @@ 'use strict'; -/* - * - * The key parameter 'pack' - * The supplied 'custom_prelude.js' file is needed for - * .load function of soop. - */ - var fs = require('fs'); var browserify = require('browserify'); var browserPack = require('browser-pack'); -var program = require('commander'); - -// concat browser vendor files var exec = require('child_process').exec; var sys = require('sys'); var puts = function(error, stdout, stderr) { @@ -21,24 +11,6 @@ var puts = function(error, stdout, stderr) { sys.puts(stderr); }; -exec('cd browser; sh concat.sh', puts); - -var list = function(val) { - return val.split(','); -}; - -program - .version('0.0.1') - .option('-a, --includeall', 'Include all submodules.') - .option('-d, --dontminify', 'Don\'t minify the code.') - .option('-s, --submodules ', 'Include the listed comma-separated submodules.', list) - .parse(process.argv); - -if (!program.includeall && (!program.submodules || program.submodules.length === 0)) { - console.log('Must use either -s or -a option. For more info use the --help option'); - process.exit(1); -} - var pack = function (params) { var file = require.resolve('soop'); var dir = file.substr(0, file.length - String('soop.js').length); @@ -82,40 +54,88 @@ var modules = [ 'util/VersionedData', ]; -var opts = {}; -opts.pack = pack; -opts.debug = true; -opts.standalone = 'bitcore'; -opts.insertGlobals = true; - -var b = browserify(opts); -b.require('browserify-bignum/bignumber.js', {expose: 'bignum'} ); -b.require('browserify-buffertools/buffertools.js', {expose:'buffertools'}); -b.require('base58-native', {expose: 'base58-native'}); -b.require('./bitcore', {expose: 'bitcore'}); -modules.forEach(function(m) { - if (program.includeall || program.submodules.indexOf(m) > -1) { - console.log('Including '+m+' in the browser bundle'); - b.require('./' + m + '.js' , {expose: './'+m} ); +var createBitcore = function(opts) { + + // concat browser vendor files + exec('cd browser; sh concat.sh', puts); + + if (!opts.includeall && (!opts.submodules || opts.submodules.length === 0)) { + console.log('Must use either -s or -a option. For more info use the --help option'); + process.exit(1); } -}); -if (!program.dontminify) { - b.transform({ - global: true - }, 'uglifyify'); -} + var bopts = { + pack : pack, + debug : true, + standalone : 'bitcore', + insertGlobals: true + }; + var b = browserify(bopts); + + b.require('browserify-bignum/bignumber.js', { + expose: 'bignum' + }); + b.require('browserify-buffertools/buffertools.js', { + expose: 'buffertools' + }); + b.require('base58-native', { + expose: 'base58-native' + }); + b.require('./bitcore', { + expose: 'bitcore' + }); + modules.forEach(function(m) { + if (opts.includeall || opts.submodules.indexOf(m) > -1) { + console.log('Including ' + m + ' in the browser bundle'); + b.require('./' + m + '.js', { + expose: './' + m + }); + } + }); + + if (!opts.dontminify) { + b.transform({ + global: true + }, 'uglifyify'); + } -var bundle = b.bundle(); -bundle = bundle.pipe(fs.createWriteStream('browser/bundle.js')); + var bundle = b.bundle(); + return bundle; +}; -opts.standalone = 'testdata'; -var tb = browserify(opts); -tb.require('./test/testdata', {expose: 'testdata'}); -tb.transform('brfs'); +var createTestData = function() { + var bopts = { + pack : pack, + debug : true, + standalone : 'testdata', + insertGlobals: true + }; + var tb = browserify(bopts); + tb.require('./test/testdata', { + expose: 'testdata' + }); + tb.transform('brfs'); + + return tb.bundle(); +}; -tb.bundle().pipe(fs.createWriteStream('browser/testdata.js')); +if (require.main === module) { + var list = function(val) { + return val.split(','); + }; + var program = require('commander'); + program + .version('0.0.1') + .option('-a, --includeall', 'Include all submodules.') + .option('-d, --dontminify', 'Don\'t minify the code.') + .option('-s, --submodules ', 'Include the listed comma-separated submodules.', list) + .parse(process.argv); + var bitcoreBundle = createBitcore(program); + var testBundle = createTestData(program); + testBundle.pipe(fs.createWriteStream('browser/testdata.js')); + bitcoreBundle.pipe(fs.createWriteStream('browser/bundle.js')); +} From e0557d0deab3c6ed2d2570b8c7170fb279edf5a2 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 13 Mar 2014 15:06:13 -0300 Subject: [PATCH 13/22] check submodule validity --- browser/build.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/browser/build.js b/browser/build.js index 56f2116..bcfc838 100644 --- a/browser/build.js +++ b/browser/build.js @@ -63,6 +63,13 @@ var createBitcore = function(opts) { console.log('Must use either -s or -a option. For more info use the --help option'); process.exit(1); } + + if (opts.submodules) { + for (var i = 0; i Date: Thu, 13 Mar 2014 15:28:14 -0300 Subject: [PATCH 14/22] add exports --- browser/build.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/browser/build.js b/browser/build.js index bcfc838..101efb1 100644 --- a/browser/build.js +++ b/browser/build.js @@ -144,5 +144,7 @@ if (require.main === module) { testBundle.pipe(fs.createWriteStream('browser/testdata.js')); bitcoreBundle.pipe(fs.createWriteStream('browser/bundle.js')); - } + +module.exports.createBitcore = createBitcore; +module.exports.createTestData = createTestData; From b1c038b4d04aa6933dd788d86909ed699a39882a Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 13 Mar 2014 16:05:04 -0300 Subject: [PATCH 15/22] add dir option --- browser/build.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/browser/build.js b/browser/build.js index 101efb1..aec2603 100644 --- a/browser/build.js +++ b/browser/build.js @@ -56,8 +56,11 @@ var modules = [ var createBitcore = function(opts) { + + opts.dir = opts.dir || ''; + // concat browser vendor files - exec('cd browser; sh concat.sh', puts); + exec('cd '+opts.dir+'browser; sh concat.sh', puts); if (!opts.includeall && (!opts.submodules || opts.submodules.length === 0)) { console.log('Must use either -s or -a option. For more info use the --help option'); From a675f4566c7145560ac561b1f32de12f29663612 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 13 Mar 2014 16:33:46 -0300 Subject: [PATCH 16/22] fix paths --- browser/build.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/browser/build.js b/browser/build.js index aec2603..d0cabdf 100644 --- a/browser/build.js +++ b/browser/build.js @@ -91,13 +91,13 @@ var createBitcore = function(opts) { b.require('base58-native', { expose: 'base58-native' }); - b.require('./bitcore', { + b.require('./'+ opts.dir +'bitcore', { expose: 'bitcore' }); modules.forEach(function(m) { if (opts.includeall || opts.submodules.indexOf(m) > -1) { console.log('Including ' + m + ' in the browser bundle'); - b.require('./' + m + '.js', { + b.require('./' + opts.dir + m + '.js', { expose: './' + m }); } From c9607e5821fa53d8e961bcf1525df6b275d4c455 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 13 Mar 2014 16:45:10 -0300 Subject: [PATCH 17/22] fix paths --- browser/build.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/browser/build.js b/browser/build.js index d0cabdf..6f98619 100644 --- a/browser/build.js +++ b/browser/build.js @@ -82,13 +82,13 @@ var createBitcore = function(opts) { }; var b = browserify(bopts); - b.require('browserify-bignum/bignumber.js', { + b.require(opts.dir + 'browserify-bignum/bignumber.js', { expose: 'bignum' }); - b.require('browserify-buffertools/buffertools.js', { + b.require(opts.dir + 'browserify-buffertools/buffertools.js', { expose: 'buffertools' }); - b.require('base58-native', { + b.require(opts.dir + 'base58-native', { expose: 'base58-native' }); b.require('./'+ opts.dir +'bitcore', { From b696dae603cf810ee51c6efdc76a171f4b95773e Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 13 Mar 2014 18:54:48 -0300 Subject: [PATCH 18/22] make stdout output possible --- browser/build.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/browser/build.js b/browser/build.js index 6f98619..469e527 100644 --- a/browser/build.js +++ b/browser/build.js @@ -60,24 +60,24 @@ var createBitcore = function(opts) { opts.dir = opts.dir || ''; // concat browser vendor files - exec('cd '+opts.dir+'browser; sh concat.sh', puts); + exec('cd ' + opts.dir + 'browser; sh concat.sh', puts); if (!opts.includeall && (!opts.submodules || opts.submodules.length === 0)) { console.log('Must use either -s or -a option. For more info use the --help option'); process.exit(1); } - + if (opts.submodules) { - for (var i = 0; i', 'Include the listed comma-separated submodules.', list) .parse(process.argv); var bitcoreBundle = createBitcore(program); var testBundle = createTestData(program); testBundle.pipe(fs.createWriteStream('browser/testdata.js')); - bitcoreBundle.pipe(fs.createWriteStream('browser/bundle.js')); + bitcoreBundle.pipe(program.stdout ? process.stdout : fs.createWriteStream('browser/bundle.js')); } module.exports.createBitcore = createBitcore; From f9d4c66c0faf99505a3b0a9f698a00593cdafc66 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 13 Mar 2014 19:10:28 -0300 Subject: [PATCH 19/22] remove extra prints --- browser/build.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/browser/build.js b/browser/build.js index 469e527..a0df956 100644 --- a/browser/build.js +++ b/browser/build.js @@ -7,8 +7,8 @@ var exec = require('child_process').exec; var sys = require('sys'); var puts = function(error, stdout, stderr) { if (error) console.log(error); - sys.puts(stdout); - sys.puts(stderr); + //sys.puts(stdout); + //sys.puts(stderr); }; var pack = function (params) { @@ -63,7 +63,7 @@ var createBitcore = function(opts) { exec('cd ' + opts.dir + 'browser; sh concat.sh', puts); if (!opts.includeall && (!opts.submodules || opts.submodules.length === 0)) { - console.log('Must use either -s or -a option. For more info use the --help option'); + if (!opts.stdout) console.log('Must use either -s or -a option. For more info use the --help option'); process.exit(1); } @@ -96,7 +96,7 @@ var createBitcore = function(opts) { }); modules.forEach(function(m) { if (opts.includeall || opts.submodules.indexOf(m) > -1) { - console.log('Including ' + m + ' in the browser bundle'); + if (!opts.stdout) console.log('Including ' + m + ' in the browser bundle'); b.require('./' + opts.dir + m + '.js', { expose: './' + m }); From 5e0ae915f2e29fe20f036411680b09a65c399921 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 13 Mar 2014 19:21:15 -0300 Subject: [PATCH 20/22] muting testdata for stdout --- browser/build.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/browser/build.js b/browser/build.js index a0df956..8635ccf 100644 --- a/browser/build.js +++ b/browser/build.js @@ -143,10 +143,11 @@ if (require.main === module) { .option('-o, --stdout', 'Specify output as stdout') .option('-s, --submodules ', 'Include the listed comma-separated submodules.', list) .parse(process.argv); + if (!program.stdout) { + var testBundle = createTestData(program); + testBundle.pipe(fs.createWriteStream('browser/testdata.js')); + } var bitcoreBundle = createBitcore(program); - var testBundle = createTestData(program); - - testBundle.pipe(fs.createWriteStream('browser/testdata.js')); bitcoreBundle.pipe(program.stdout ? process.stdout : fs.createWriteStream('browser/bundle.js')); } From eb90bc152be7038feaa0c6b7081f29a75f79eeff Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 13 Mar 2014 19:23:04 -0300 Subject: [PATCH 21/22] base dir --- browser/build.js | 1 + 1 file changed, 1 insertion(+) diff --git a/browser/build.js b/browser/build.js index 8635ccf..27718ea 100644 --- a/browser/build.js +++ b/browser/build.js @@ -141,6 +141,7 @@ if (require.main === module) { .option('-a, --includeall', 'Include all submodules.') .option('-d, --dontminify', 'Don\'t minify the code.') .option('-o, --stdout', 'Specify output as stdout') + .option('-D, --dir', 'Specify a base directory') .option('-s, --submodules ', 'Include the listed comma-separated submodules.', list) .parse(process.argv); if (!program.stdout) { From e8013cfed0b155d6f652f2d801aff35ee4f0708a Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 13 Mar 2014 19:55:26 -0300 Subject: [PATCH 22/22] fix dir --- browser/build.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser/build.js b/browser/build.js index 27718ea..14f14ed 100644 --- a/browser/build.js +++ b/browser/build.js @@ -141,7 +141,7 @@ if (require.main === module) { .option('-a, --includeall', 'Include all submodules.') .option('-d, --dontminify', 'Don\'t minify the code.') .option('-o, --stdout', 'Specify output as stdout') - .option('-D, --dir', 'Specify a base directory') + .option('-D, --dir ', 'Specify a base directory') .option('-s, --submodules ', 'Include the listed comma-separated submodules.', list) .parse(process.argv); if (!program.stdout) {