Skip to content

Instantly share code, notes, and snippets.

@mootari
Created January 14, 2018 18:54
Show Gist options
  • Save mootari/cb44a9d7c48434f1561d7b0ea91dbf31 to your computer and use it in GitHub Desktop.
Save mootari/cb44a9d7c48434f1561d7b0ea91dbf31 to your computer and use it in GitHub Desktop.
const app = require('assemble')();
app.use(require('./task-namespace')());
// Shared init task for all sources.
app.task('init', function(next) {
//app.layouts(abs(config.layouts));
//app.partials(abs(config.partials));
next();
});
// Shared build task for all sources.
app.task('build', ['init']);
app.use(require('./source-guide')('guide', {}));
module.exports = app;
module.exports = function(name, options) {
return function run(app) {
const addTask = app.taskNamespace(name);
const collection = app.create(name, {
engine: 'hbs',
});
addTask('init', function(next) {
//collection.addViews(options.src);
next();
});
addTask('build', ['init'], function(next) {
return collection.toStream();
// .pipe(app.renderFile())
// .pipe(app.dest(options.dest));
});
}
};
module.exports = function(options) {
return function(app) {
app.define('taskNamespace', function(namespace) {
return function(taskName, deps, fn) {
if(!fn && typeof deps === 'function') {
fn = deps;
}
if(!Array.isArray(deps)) {
deps = [];
}
deps = deps.map(fullName);
app.task(fullName(taskName), deps, fn);
if(!app.tasks.hasOwnProperty(taskName)) {
app.task(taskName, []);
}
app.tasks[taskName].deps.push(fullName(taskName));
};
function fullName(taskName) {
return taskName + ':' + namespace;
}
});
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment