Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

now using browserify@1.2.1's require() with targets

  • Loading branch information...
commit 4bca3b6dcd13ae611356e5de8809f28aceebd71d 1 parent eded1a3
@substack authored
Showing with 10 additions and 13 deletions.
  1. +9 −12 index.js
  2. +1 −1  package.json
View
21 index.js
@@ -3,8 +3,8 @@ var path = require('path');
var findit = require('findit');
var Seq = require('seq');
-module.exports = function (name, dir, ext) {
- if (!name) throw new Error('Name required');
+module.exports = function (target, dir, ext) {
+ if (!target) throw new Error('Target name required');
if (!dir) throw new Error('Directory or files required');
return function (bundle) {
@@ -38,15 +38,12 @@ module.exports = function (name, dir, ext) {
return acc;
}, {});
- bundle.register(function (body, file) {
- if (file === __dirname + '/browser/files.js') {
- return body.replace(/\$bodies/, function () {
- return JSON.stringify(bodies);
- });
- }
- else return body;
- });
-
- bundle.require(__dirname + '/browser/files.js');
+ var file = __dirname + '/browser/files.js';
+ var body = fs.readFileSync(file, 'utf8')
+ .replace(/\$bodies/, function () {
+ return JSON.stringify(bodies);
+ })
+ ;
+ bundle.include(file, path.normalize('/' + target), body);
};
};
View
2  package.json
@@ -12,7 +12,7 @@
"seq" : ">=0.2.5 <0.3"
},
"devDependencies" : {
- "browserify" : "1.2.x",
+ "browserify" : ">=1.2.1 <1.3",
"expresso" : "0.7.x"
},
"scripts" : {
Please sign in to comment.
Something went wrong with that request. Please try again.