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

piping gulp nodemon output through Bunyan (or whatever) #103

Open
ORESoftware opened this issue Feb 2, 2016 · 3 comments
Open

piping gulp nodemon output through Bunyan (or whatever) #103

ORESoftware opened this issue Feb 2, 2016 · 3 comments

Comments

@ORESoftware
Copy link

I am a big fan of gulp-nodemon, but I cannot figure out how to pipe it through Bunyan

I have to do this:

$ gulp nodemon | bunyan -l debug -o short

but I would rather do something like this:

$ gulp nodemon

with " | bunyan -l debug -o short" as some sort of argument using this:

gulp.task('nodemon', ['metagen:all', 'watch:hot-reload-front-end'], function () {

    nodemon({

        script: 'bin/www.js',
        ext: 'js',
        ignore: ['public/*', '*.git/*', '*.idea/*', 'routes/*', 'gulpfile.js'],
        args: ['--use_socket_serverX', '--use_hot_reloader', ' | bunyan -o short'],  // <<<< this bunyan call doesn't work
        nodeArgs: [],
        env: {
            NODE_ENV: 'development'
        }

    }).on('restart', []);

});

I am just being stoopid and not using the right command or is there something else wrong?

@ColemanGariety
Copy link
Owner

Try this solution contributed by @markstos:

gulp.task('run', ['default', 'watch'], function() {
    var nodemon = require('gulp-nodemon'),
        spawn   = require('child_process').spawn,
        bunyan

    nodemon({
        script: paths.server,
        ext:    'js json',
        ignore: [
            'var/',
            'node_modules/'
        ],
        watch:    [paths.etc, paths.src],
        stdout:   false,
        readable: false
    })
    .on('readable', function() {

        // free memory
        bunyan && bunyan.kill()

        bunyan = spawn('./node_modules/bunyan/bin/bunyan', [
            '--output', 'short',
            '--color'
        ])

        bunyan.stdout.pipe(process.stdout)
        bunyan.stderr.pipe(process.stderr)

        this.stdout.pipe(bunyan.stdin)
        this.stderr.pipe(bunyan.stdin)
    });
})

@ColemanGariety
Copy link
Owner

ColemanGariety commented Feb 3, 2016

But that is way too complicated. It would be nice to be able to do something like this:

nodemon().pipe(bunyan.stream)

EDIT: tagged 'enhancement'

@ORESoftware
Copy link
Author

ok thanks, yeah I have been struggling with it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants