Permalink
Browse files

added manifest(). closes #12

  • Loading branch information...
1 parent b43e8d5 commit 7a2c0034b8381f7b2055366fc74e6122b0847e3b @danwrong committed Feb 5, 2012
Showing with 26 additions and 4 deletions.
  1. +14 −1 lib/loadbuilder/builder.js
  2. +2 −1 package.json
  3. +10 −2 test/builder.js
View
@@ -157,11 +157,24 @@ util.extend(Builder.prototype, {
return source;
},
+ manifest: function() {
+ return this.collectedAssets().map(function(dep) {
+ return dep.id;
+ });
+ },
write: function(path, success) {
+ var manifest = this.manifest(),
+ res = {};
+
+ res[path] = manifest;
fs.writeFile(
path, this.toSource(),
- 'utf8', success || function() {}
+ 'utf8', function() {
+ if (success) {
+ success(res);
+ }
+ }
);
this.log('> ' + path);
View
@@ -11,7 +11,8 @@
"jshint": ">=0",
"opts": ">=1.2.1",
"uglify-js": ">=0.0.5",
- "colors": ">=0.5.0"
+ "colors": ">=0.5.0",
+ "glob": ">=3"
},
"devDependencies": {
"expresso": ">=0.9.2"
View
@@ -32,6 +32,12 @@ module.exports = {
builder(opts).include('fixtures/has_dep.js').toSource()
);
},
+ testShouldGenerateManifestList: function() {
+ assert.deepEqual(
+ ["fixtures/dep1dep.js","fixtures/dep1.js","fixtures/dep2.js","fixtures/has_dep.js"],
+ builder(opts).include('fixtures/has_dep.js').manifest()
+ );
+ },
testShouldExcludeDependenciesOfExcludedAsset: function() {
assert.equal(
"alert('hello');\nusing('fixtures/dep1.js', 'fixtures/dep2.js');",
@@ -52,9 +58,11 @@ module.exports = {
);
},
testShouldBeAbleToWriteToAFile: function() {
- var path = __dirname + '/bundle.js';
- builder(opts).include('fixtures/simple.js', 'fixtures/simple2.js').write(path, function() {
+ var path = __dirname + '/bundle.js', expected = {};
+ builder(opts).include('fixtures/simple.js', 'fixtures/simple2.js').write(path, function(manifest) {
assert.equal("alert('hello world');\nalert('hello world again');",fs.readFileSync(path, 'utf8'));
+ expected[path] = ["fixtures/simple.js","fixtures/simple2.js"];
+ assert.deepEqual(expected, manifest);
fs.unlinkSync(path);
});
},

0 comments on commit 7a2c003

Please sign in to comment.