gobblejs / gobble

The last build tool you'll ever need
333 stars 20 forks source link

Consolidate logging #57

Open lukescott opened 9 years ago

lukescott commented 9 years ago

This is sort of a feature request. gobble-cli has a great logger. The code in grunt-gobble seems very similar. I'm using gulp to kick off the build process, and this is currently what I'm doing:

gulp.task("build", function(cb) {
    var logger = require("gobble-cli/lib/utils/logger")
    var node = require("./gobblefile.js");
    var task = node.build({
        dest: "dist",
        force: true
    });

    task.catch( function ( err ) {
        logger.error( err );
        cb();
    });

    task.on("info",  logger.info);
    task.on("error", logger.error);

    task.on("complete", function() {
        cb();
    });
});

I'm cheating a bit by including gobble-cli's logger :sweat_smile:. And much of the code is inspired from the cli. It would be nice if you could do something like this instead:

gulp.task("build", function(cb) {
    require("./gobblefile.js").build({
        dest: "dist",
        force: true,
        logger: true
    }, cb); // <-- cb: let gulp know when finished
});

I know it's not that great of reduction line wise, but it makes the API more friendly. This would help out a great deal with many CI/CLI tools that may integrate gobble.