Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions lib/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,18 +480,20 @@ function resolveMiddlewareParams(rootDir, params) {
}

function buildComponentInstructions(rootDir, componentConfig) {
return Object.keys(componentConfig).map(function(name) {
var sourceFile;
if (name.indexOf('./') === 0 || name.indexOf('../') === 0) {
// Relative path
sourceFile = path.resolve(rootDir, name);
} else {
sourceFile = require.resolve(name);
}
return Object.keys(componentConfig)
.filter(function(name) { return !!componentConfig[name]; })
.map(function(name) {
var sourceFile;
if (name.indexOf('./') === 0 || name.indexOf('../') === 0) {
// Relative path
sourceFile = path.resolve(rootDir, name);
} else {
sourceFile = require.resolve(name);
}

return {
sourceFile: sourceFile,
config: componentConfig[name]
};
});
return {
sourceFile: sourceFile,
config: componentConfig[name]
};
});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you using tab characters here? Please ensure you use only spaces for indentation (you may need to change the settings in your editor).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've used space character here for indentation. I also cross-verified the editor settings. And it is set to use "spaces" only for indentation. Although not sure, why does it highlight here in green!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it's GitHub's way of showing that the line differs in whitespace only. Don't worry about that then.

}
18 changes: 18 additions & 0 deletions test/executor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,27 @@ describe('executor', function() {

boot(app, appdir.PATH);

expect(Object.keys(require.cache)).to.include(
appdir.resolve('components/test-component/index.js'));

expect(app.componentOptions).to.eql({ option: 'value' });
});

it('disables component when configuration is not set', function() {
appdir.writeConfigFileSync('component-config.json', {
'./components/test-component': false
});

appdir.writeFileSync('components/test-component/index.js',
'module.exports = ' +
'function(app, options) { app.componentOptions = options; }');

boot(app, appdir.PATH);

expect(Object.keys(require.cache)).to.not.include(
appdir.resolve('components/test-component/index.js'));
});

it('configures middleware (that requires `this`)', function(done) {
var passportPath = require.resolve('./fixtures/passport');

Expand Down