Comparing version 0.5.3 to 0.5.4
@@ -35,3 +35,4 @@ var assert = require("assert"); | ||
resolvers = hashCallbacks("resolvers", resolvers, warnMissingModule); | ||
processors = hashCallbacks("processors", processors); | ||
processors = hashCallbacks( | ||
"processors", processors, require("./relative").relativizeP); | ||
@@ -38,0 +39,0 @@ Object.defineProperties(self, { |
@@ -17,3 +17,3 @@ { | ||
], | ||
"version": "0.5.3", | ||
"version": "0.5.4", | ||
"homepage": "http://github.com/benjamn/commoner", | ||
@@ -33,2 +33,3 @@ "repository": { | ||
"q": ">= 0.9.1", | ||
"recast": ">= 0.3.3", | ||
"commander": ">= 1.1.1", | ||
@@ -35,0 +36,0 @@ "mkdirp": ">= 0.3.5", |
@@ -18,6 +18,13 @@ Commoner | ||
static file server, or bundled together using a tool such as | ||
[Browserify](https://github.com/substack/node-browserify) or | ||
[Browserify](https://github.com/substack/node-browserify), | ||
[WrapUp](https://github.com/kamicane/wrapup), or | ||
[Stitch](https://github.com/sstephenson/stitch) for delivery to a web | ||
browser. | ||
Commoner also takes care to rewrite all `require` calls to use relative | ||
module identifiers, so that the output files can be installed into any | ||
subdirectory of a larger project, and external tools do not have to give | ||
special treatment to top-level modules (or even know which modules are | ||
top-level and which are nested). | ||
Commoner was derived from an earlier, more opinionated tool called | ||
@@ -24,0 +31,0 @@ [Brigade](https://github.com/benjamn/brigade) that provided additional |
@@ -44,3 +44,3 @@ var Watcher = require("../lib/watcher").Watcher; | ||
assert.notEqual(home.source.indexOf("exports"), -1); | ||
assert.strictEqual(home.source.indexOf('require("assert");'), 0); | ||
assert.strictEqual(home.source.indexOf('require("./assert");'), 0); | ||
return home; | ||
@@ -149,1 +149,39 @@ }).invoke("getRequiredP").then(function(reqs) { | ||
}; | ||
exports.testRelativize = function(t, assert) { | ||
var relativizeP = require("../lib/relative").relativizeP; | ||
function helperP(requiredId, expected) { | ||
return relativizeP( | ||
"some/deeply/nested/module", | ||
"require(" + JSON.stringify(requiredId) + ")" | ||
).then(function(source) { | ||
assert.strictEqual( | ||
source, | ||
"require(" + JSON.stringify(expected) + ")" | ||
); | ||
}); | ||
} | ||
Q.all([ | ||
helperP("another/nested/module", | ||
"../../../another/nested/module"), | ||
helperP("../../buried/module/./file", | ||
"../../buried/module/file"), | ||
helperP("../../buried/module/../file", | ||
"../../buried/file"), | ||
helperP("./same/level", | ||
"./same/level"), | ||
helperP("./same/./level", | ||
"./same/level"), | ||
helperP("./same/../level", | ||
"./level"), | ||
helperP("some/deeply/buried/treasure", | ||
"../buried/treasure"), | ||
helperP("./file", "./file"), | ||
helperP("./file/../../../module", | ||
"../../module"), | ||
helperP("./file/../../module", | ||
"../module") | ||
]).done(t.finish.bind(t)); | ||
}; |
47939
31
1061
289
6
+ Addedrecast@>= 0.3.3
+ Addedast-types@0.16.1(transitive)
+ Addedesprima@4.0.1(transitive)
+ Addedrecast@0.23.9(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedtiny-invariant@1.3.3(transitive)
+ Addedtslib@2.8.1(transitive)