edt
edt

Reputation: 22440

How can I use Gulp to run a Node JS app?

I have a node app "generate.js" that generates a set of static files.

My goal is that when ever any files in /foo/ directory are modified, that generate.js is run once.

And, I would like to do this using a Gulp watch task.

In the past, I have done similar using Grunt and the grunt-execute plugin. But, I haven't found a way to do it with Gulp.

Upvotes: 0

Views: 128

Answers (1)

panta82
panta82

Reputation: 2721

Gulp code is ordinary javascript. So you can just run your process using node's built in child_process module.

var cp = import('child_process');

gulp.task('taskname', function(callback) {
    // Start your child process here
    cp.spawn(/*...*/);
});

Upvotes: 1

Related Questions