Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect entry validation #171

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 22 additions & 1 deletion index.js
Expand Up @@ -25,6 +25,27 @@ var defaultStatsOptions = {
errorDetails: false
};

function validEntry (entry) {
if (!entry) {
return false;
}

// Arrays and strings
if (entry.length > 1) {
return true;
}

var type = typeof entry;

// Objects and promises
if (type === 'object' && !entry.then && Object.getOwnPropertyNames(entry)) {
return false;
}

// Functions
return type === 'function';
}

module.exports = function (options, wp, done) {
options = clone(options) || {};
var config = options.config || options;
Expand Down Expand Up @@ -106,7 +127,7 @@ module.exports = function (options, wp, done) {
config.watch = options.watch;
entry = [];

if (!config.entry || config.entry.length < 1) {
if (!validEntry(config.entry)) {
gutil.log('webpack-stream - No files given; aborting compilation');
self.emit('end');
return false;
Expand Down