Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

refactoring path/module lookup to allow absolute paths

  • Loading branch information...
commit d65b0600d2a43341e602008ed4bd955412cbaba9 1 parent 85b7d34
@nickjackson nickjackson authored
Showing with 15 additions and 7 deletions.
  1. +4 −6 bin/component-build
  2. +11 −1 test/build.js
View
10 bin/component-build
@@ -83,13 +83,11 @@ if (conf.paths) builder.addLookup(conf.paths);
if (program.use) {
var modules = program.use.split(',');
modules.forEach(function(mod){
- // check for absolute path or local module
- var abs = exists(mod) || exists(mod + '.js');
- mod = abs ?
- path.join(process.cwd(), mod) :
- path.join(process.cwd(), 'node_modules', mod);
+ var resolved = path.resolve(mod)
+ , real = exists(resolved) || exists(resolved + '.js')
+ , module = path.resolve('node_modules', mod);
- builder.use(require(mod));
+ builder.use(real ? require(resolved) : require(module));
});
}
View
12 test/build.js
@@ -29,7 +29,7 @@ describe('component build', function(){
})
})
- it('should require middleware', function(done){
+ it('should require middleware with relative path', function(done){
exec('cd test/fixtures/path && ' + bin + '-build -v -u ../plugin', function(err, stdout){
if (err) return done(err);
stdout.should.include('middleware fired!');
@@ -37,4 +37,14 @@ describe('component build', function(){
done();
})
})
+
+ it('should require middleware with absolute path', function(done){
+ var plugin = path.join(__dirname, 'fixtures', 'plugin');
+ exec('cd test/fixtures/path && ' + bin + '-build -v -u ' + plugin, function(err, stdout){
+ if (err) return done(err);
+ stdout.should.include('middleware fired!');
+ stdout.should.include('builder config fired!');
+ done();
+ })
+ })
})
Please sign in to comment.
Something went wrong with that request. Please try again.