Permalink
Browse files

get all tests passing... i think ender is back to working!! hooray!:D

  • Loading branch information...
fat committed Jul 5, 2011
1 parent 08a0b54 commit 27862e3e8553eed00322fca490580be790ebd2d1
Showing with 89 additions and 100 deletions.
  1. +3 −3 lib/ender.cmd.js
  2. +7 −12 lib/ender.file.js
  3. +0 −2 lib/ender.get.js
  4. +1 −6 lib/ender.js
  5. +5 −7 lib/ender.npm.js
  6. +73 −70 test/test.js
View
@@ -20,15 +20,15 @@ module.exports = {
size = 0
if (option == '-o' || option == '--output') {
option = 'output'
- value = args[i + 1] && args[i + 1].replace(/\.js$/, '')
+ value = cmdOptions[i + 1] && cmdOptions[i + 1].replace(/\.js$/, '')
size = 2
} else if (option == '--use' || option == '-u') {
option = 'use'
- value = args[i + 1] && args[i + 1].replace(/\.js$/, '')
+ value = cmdOptions[i + 1] && cmdOptions[i + 1].replace(/\.js$/, '')
size = 2
} else if (option == '--max') {
option = 'max'
- value = args[i + 1]
+ value = cmdOptions[i + 1]
size = 2
} else if (option == '--noop' || option == '-x'){
option = 'noop'
View
@@ -98,7 +98,7 @@ ENDER.file = module.exports = {
}
})
- function writeSize (err, data) {
+ function writeSize (data) {
console.log('Your current build type is ' + ('"' + type + '"').yellow)
console.log('Your current library size is ' + ((Math.round((data.length/1024) * 10) / 10) + '').yellow + ' kb\n')
callback && callback()
@@ -273,14 +273,9 @@ ENDER.file = module.exports = {
}
, findDependencies: function (data, tree, directory, isInstallingFromRoot, callback) {
- var packageJSON
- , dependencies
- , packageJSON
- , dependencies
-
- packageJSON = JSON.parse(data)
- packageName = packageJSON.name
- dependencies = packageJSON.dependencies
+ var packageJSON = JSON.parse(data)
+ , dependencies = packageJSON.dependencies
+ , packageName = packageJSON.name
if (!dependencies) {
tree[packageName] = 0
@@ -290,7 +285,7 @@ ENDER.file = module.exports = {
dependencies = Object.keys(dependencies)
if (isInstallingFromRoot) {
- return ENDER.file.constructDependencyTree(dependencies, dir, function (err, result) {
+ return ENDER.file.constructDependencyTree(dependencies, directory, function (err, result) {
tree = ENDER.util.merge(tree, result)
callback(null, tree)
})
@@ -306,7 +301,7 @@ ENDER.file = module.exports = {
} else if (dependencies.length) {
tree[packageName] = tree[packageName] || {}
dependencies.forEach(function (item) {
- tree[name][item] = -1
+ tree[packageName][item] = -1
})
} else {
tree[packageName] = 0
@@ -324,7 +319,7 @@ ENDER.file = module.exports = {
ENDER.file.constructDependencyTree(filenames, directory, function (err, subTree) {
tree[packageName] = subTree
if (filenames.length != dependencies.length) {
- UTIL.reject(dependencies, filenames).forEach(function (item) {
+ ENDER.util.reject(dependencies, filenames).forEach(function (item) {
tree[packageName][item] = -1
})
}
View
@@ -19,8 +19,6 @@ module.exports = {
} else if(/\.min\.js$/.test(file)) {
console.log('Active Ender library couldn\'t be found.')
callback(new Error)
- } else {
- ENDER.get.prettyPrintEnderSize(type, file.replace(/\.js$/, '.min'), callback)
}
})
View
@@ -25,7 +25,7 @@ var colors = require('colors')
// ENDER'S API DEFINITION
// ======================
- , API = {
+ , API = module.exports = {
search: ENDER.search
@@ -209,11 +209,6 @@ var colors = require('colors')
}
-// EXPOSE BASE API METHODS
-// =======================
-
-ENDER.util.merge(module.exports, API)
-
// ALIAS CLI WITH EXTRA METHODS
// ============================
View
@@ -3,18 +3,16 @@ var path = require('path')
, fs = require('fs')
, npm = require('npm')
, async = require('async')
- , ENDER = { file: require('./ender.file')
- , npm: module.exports
- }
+ , ENDER = { file: require('./ender.file') }
-module.exports = {
+ENDER.npm = module.exports = {
prettyPrintDependencies: function (packages, callback) {
console.log('Active packages:')
- FILE.constructDependencyTree(packages, 'node_modules', function (err, tree) {
- FILE.flattenDependencyTree(tree, null, function (err, flattenedPackages, uniquePackages) {
- NPM.recurseOverDependencies(tree, [flattenedPackages, uniquePackages])
+ ENDER.file.constructDependencyTree(packages, 'node_modules', function (err, tree) {
+ ENDER.file.flattenDependencyTree(tree, null, function (err, flattenedPackages, uniquePackages) {
+ ENDER.npm.recurseOverDependencies(tree, [flattenedPackages, uniquePackages])
})
})
}
View
@@ -4,13 +4,12 @@ var spec = require('sink-test')
, ender = require('../lib/ender')
, O_O = require('./O_O')
, path = require('path')
- , sys = require('sys')
, fs = require('fs');
// don't allow timeouts!
sink.timeout = false;
-//only output sink log statements
+// only output sink log statements
spec.setLogKey('$__sink::');
sink('ENDER - DEPENDENCIES', function (test, ok, before, after) {
@@ -86,12 +85,12 @@ sink('ENDER - BUILD', function (test, ok, before, after) {
});
});
- test('exec: ender -b domready', 2, function () {
+ test('exec: ender build domready', 2, function () {
O_O(ender, 'build').andCallFake(function (packages) {
ok(true, 'build was called');
ok(packages.length == 1 && packages[0] == 'domready', 'correct packages passed');
});
- ender.exec('ender -b domready');
+ ender.exec('ender build domready');
});
});
@@ -242,7 +241,8 @@ sink('ENDER - NOOP', function (test, ok, before, after) {
test('dependency display 1', 2, function () {
var i = 0;
- O_O(NPM, 'log').andCallFake(function (str) {
+ O_O(console, 'log').andCallFake(function (str) {
+ if (/\$\_\_sink\:\:/.test(str)) return;
i++;
if (i === 1) ok ('├── ' + 'foo'.yellow == str, str);
else if (i === 2) ok ('└── ' + 'bar'.yellow == str, str);
@@ -253,87 +253,90 @@ sink('ENDER - NOOP', function (test, ok, before, after) {
bar: 0
}
- NPM.prettyPrintDependencies(tree);
+ NPM.recurseOverDependencies(tree);
});
test('dependency display 2', 4, function () {
- var i = 0
- , tree = {
- foo: 0,
- bar: {
- baz: 0,
- bang: 0
+ var i = 0
+ , tree = {
+ foo: 0,
+ bar: {
+ baz: 0,
+ bang: 0
+ }
}
- }
-
- O_O(NPM, 'log').andCallFake(function (str) {
- i++;
- if (i === 1) ok ('├── ' + 'foo'.yellow == str, str + ' was output');
- else if (i === 2) ok ('└─┬ ' + 'bar'.yellow == str, str + ' was output');
- else if (i === 3) ok (' ├── ' + 'baz'.yellow == str, str + ' was output');
- else if (i === 4) ok (' └── ' + 'bang'.yellow == str, str + ' was output');
- });
- NPM.prettyPrintDependencies(tree);
+ O_O(console, 'log').andCallFake(function (str) {
+ if (/\$\_\_sink\:\:/.test(str)) return;
+ i++;
+ if (i === 1) ok ('├── ' + 'foo'.yellow == str, str + ' was output');
+ else if (i === 2) ok ('└─┬ ' + 'bar'.yellow == str, str + ' was output');
+ else if (i === 3) ok (' ├── ' + 'baz'.yellow == str, str + ' was output');
+ else if (i === 4) ok (' └── ' + 'bang'.yellow == str, str + ' was output');
+ });
- });
+ NPM.recurseOverDependencies(tree);
- test('dependency display 3', 5, function () {
- var i = 0
- , tree = {
- foo: 0,
- bar: {
- baz: 0,
- bang: 0
- },
- fat: 0
- }
-
- O_O(NPM, 'log').andCallFake(function (str) {
- i++;
- if (i === 1) ok ('├── ' + 'foo'.yellow == str, '├── foo was output');
- else if (i === 2) ok ('├─┬ ' + 'bar'.yellow == str, '├─┬ bar was output');
- else if (i === 3) ok ('| ├── ' + 'baz'.yellow == str, '| ├── baz was output');
- else if (i === 4) ok ('| └── ' + 'bang'.yellow == str, '| └── bang was output');
- else if (i === 5) ok ('└── ' + 'fat'.yellow == str, '└── fat was output');
});
- NPM.prettyPrintDependencies(tree);
+ test('dependency display 3', 5, function () {
+ var i = 0
+ , tree = {
+ foo: 0,
+ bar: {
+ baz: 0,
+ bang: 0
+ },
+ fat: 0
+ }
- });
+ O_O(console, 'log').andCallFake(function (str) {
+ if (/\$\_\_sink\:\:/.test(str)) return;
+ i++;
+ if (i === 1) ok ('├── ' + 'foo'.yellow == str, '├── foo was output');
+ else if (i === 2) ok ('├─┬ ' + 'bar'.yellow == str, '├─┬ bar was output');
+ else if (i === 3) ok ('| ├── ' + 'baz'.yellow == str, '| ├── baz was output');
+ else if (i === 4) ok ('| └── ' + 'bang'.yellow == str, '| └── bang was output');
+ else if (i === 5) ok ('└── ' + 'fat'.yellow == str, '└── fat was output');
+ });
- test('dependency display 4', 8, function () {
- var i = 0
- , tree = {
- foo: 0,
- bar: {
- baz: {
- blip: 0
- },
- bang: {
- ded: 0,
- killface: 0
- }
- },
- fat: 0
- }
+ NPM.recurseOverDependencies(tree);
- O_O(NPM, 'log').andCallFake(function (str) {
- i++;
- if (i === 1) ok ('├── ' + 'foo'.yellow == str, str + ' was output');
- else if (i === 2) ok ('├─┬ ' + 'bar'.yellow == str, str + ' was output');
- else if (i === 3) ok ('| ├─┬ ' + 'baz'.yellow == str, str + ' was output');
- else if (i === 4) ok ('| | └── ' + 'blip'.yellow == str, str + ' was output');
- else if (i === 5) ok ('| └─┬ ' + 'bang'.yellow == str, str + ' was output');
- else if (i === 6) ok ('| ├── ' + 'ded'.yellow == str, str + ' was output');
- else if (i === 7) ok ('| └── ' + 'killface'.yellow == str, str + ' was output');
- else if (i === 8) ok ('└── ' + 'fat'.yellow == str, str + ' was output');
});
- NPM.prettyPrintDependencies(tree);
+ test('dependency display 4', 8, function () {
+ var i = 0
+ , tree = {
+ foo: 0,
+ bar: {
+ baz: {
+ blip: 0
+ },
+ bang: {
+ ded: 0,
+ killface: 0
+ }
+ },
+ fat: 0
+ }
+
+ O_O(console, 'log').andCallFake(function (str) {
+ if (/\$\_\_sink\:\:/.test(str)) return;
+ i++;
+ if (i === 1) ok ('├── ' + 'foo'.yellow == str, str + ' was output');
+ else if (i === 2) ok ('├─┬ ' + 'bar'.yellow == str, str + ' was output');
+ else if (i === 3) ok ('| ├─┬ ' + 'baz'.yellow == str, str + ' was output');
+ else if (i === 4) ok ('| | └── ' + 'blip'.yellow == str, str + ' was output');
+ else if (i === 5) ok ('| └─┬ ' + 'bang'.yellow == str, str + ' was output');
+ else if (i === 6) ok ('| ├── ' + 'ded'.yellow == str, str + ' was output');
+ else if (i === 7) ok ('| └── ' + 'killface'.yellow == str, str + ' was output');
+ else if (i === 8) ok ('└── ' + 'fat'.yellow == str, str + ' was output');
+ });
- });
+ NPM.recurseOverDependencies(tree);
+
+ });
});

0 comments on commit 27862e3

Please sign in to comment.