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

Working excludes example #23

Merged
merged 3 commits into from Aug 12, 2013
Merged
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
45 changes: 24 additions & 21 deletions lib/compile.js
Expand Up @@ -140,28 +140,26 @@ function (when, sequence, getCtx, scan) {
plugin = fileCtx.plugin && fileCtx.plugin();
dfd = when.defer();

if (plugin) {
if (plugin.compile) {
pio = {
write: resolve,
read: function (absId, callback, errback) {
var url = parentCtx.toUrl(absId);
when(io.readFile(url), callback, errback);
},
error: dfd.reject,
warn: (console.warn ? console.warn : console.log).bind(console),
info: console.log.bind(console)
};
plugin.compile(fileCtx.pluginId, fileCtx.resourceId, parentCtx.require, pio, parentCtx.config);
}
else {
// the resource is not included in the output
resolve('');
}
}
else {
if (inExcludeList(parentCtx, fileCtx.absId) || (plugin && !plugin.compile)) {
// 1 - Set to blank as we're excluding the module later. If the file doesn't
// exist then it won't fall over either.
// 2 - If plugin with no compile, then its not included in the output either
resolve('');
} else if (plugin) {
pio = {
write: resolve,
read: function (absId, callback, errback) {
var url = parentCtx.toUrl(absId);
when(io.readFile(url), callback, errback);
},
error: dfd.reject,
warn: (console.warn ? console.warn : console.log).bind(console),
info: console.log.bind(console)
};
plugin.compile(fileCtx.pluginId, fileCtx.resourceId, parentCtx.require, pio, parentCtx.config);
} else {
// get the text of the module
when(io.readModule(fileCtx), resolve, dfd.reject);
when(io.readModule(fileCtx), resolve, dfd.reject);
}

return dfd.promise;
Expand All @@ -172,6 +170,11 @@ function (when, sequence, getCtx, scan) {
}
}

function inExcludeList(parentCtx, moduleStr) {
var excludes = parentCtx.config.excludes;
return excludes && excludes.indexOf(moduleStr) > -1;
}

function parseModules (io, parentCtx, fileCtx) {
var prettifier, results;
prettifier = prettifyMessage.bind(null, fileCtx);
Expand Down