Skip to content

Commit

Permalink
fix bug where assemblefiles exported as a function
Browse files Browse the repository at this point in the history
were not loaded
  • Loading branch information
jonschlinkert committed Jun 3, 2016
1 parent 3ac6620 commit 5e30ace
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions bin/cli.js
Expand Up @@ -7,15 +7,13 @@ var utils = require('../lib/utils');
var errors = require('./errors');
var assemble = require('..');

var argv = require('minimist')(process.argv.slice(2), {
alias: {
help: 'h',
verbose: 'v'
}
var argv = require('yargs-parser')(process.argv.slice(2), {
alias: {help: 'h', verbose: 'v'}
});

function run(cb) {
var cwd = process.cwd();
var app;

/**
* Set the working directory
Expand All @@ -42,20 +40,15 @@ function run(cb) {
* Notify the user if assemblefile.js is not found
*/

if (!utils.exists(assemblefile)) {
cb('assemblefile');
return;
}

/**
* Get the `assemble` instance to use
*/

var app = require(assemblefile);
if (Object.keys(app).length === 0) {
var msg = util.format(errors['instance'], utils.homeRelative(assemblefile));
cb(new Error(msg));
return;

if (utils.exists(assemblefile)) {
app = require(assemblefile);
} else {
app = require('../lib/generator');
}

/**
Expand All @@ -69,6 +62,10 @@ function run(cb) {
app.option(argv);
app.fn = fn;
fn(app);
} else if (Object.keys(app).length === 0) {
var msg = util.format(errors['instance'], utils.homeRelative(assemblefile));
cb(new Error(msg));
return;
}

/**
Expand Down

0 comments on commit 5e30ace

Please sign in to comment.