browserify-rfr
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -47,2 +47,3 @@ var _ = require('lodash'); | ||
var content = ""; | ||
if (/\.json$/.test(file)) return through(); | ||
@@ -56,2 +57,10 @@ return through(function write (buf) { | ||
function callTransform(_content) { | ||
var shebang = ""; | ||
if (_content[0] == '#') { | ||
var lines = _content.split('\n'); | ||
shebang = lines[0]; | ||
_content = lines.slice(1).join('\n'); | ||
} | ||
var data = ""; | ||
@@ -74,2 +83,4 @@ var transform = transforms[i]; | ||
i = i + 1; | ||
if (shebang) data = shebang+'\n'+data; | ||
callTransform(data); | ||
@@ -76,0 +87,0 @@ } |
{ | ||
"name": "browserify-rfr", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"homepage": "https://github.com/SamyPesse/browserify-rfr", | ||
@@ -5,0 +5,0 @@ "description": "Require From project Root tool for browserify", |
@@ -8,4 +8,5 @@ var expect = require('chai').expect; | ||
describe('browserify-rfr', function() { | ||
var fixtures = path.resolve(__dirname, 'fixtures'); | ||
it('should correctly replaced "rfr()" calls', function(done) { | ||
var fixtures = path.resolve(__dirname, 'fixtures'); | ||
var b = browserify(); | ||
@@ -28,3 +29,22 @@ | ||
}); | ||
it('should correctly handle file starting with shebang', function(done) { | ||
var b = browserify(); | ||
b.transform(rfr, { | ||
root: fixtures | ||
}) | ||
.add(path.resolve(fixtures, 'shebang.js')); | ||
b.bundle(function(err, data) { | ||
if (err) return done(err); | ||
data = data.toString(); | ||
expect(data).to.contain('module.exports = 1;'); | ||
expect(data).to.contain('module.exports = require("./../t2");'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6158
10
123