I'm trying to use gulp to activate a virtualenv for python and launch a django server. Although I can launch the server correctly I can't activate the virtualenv beforehand. (this breaks integration with my IDE's gulp tool). Is there a way to make the virtualenv spawn launch first and be part of the child process that launches the server (as the server depends on being in the virtual environment).
gulpfile.js
gulp.task('runServer', function(cb) {
var virtualenv = spawn('source venv/bin/activate')
var cmd = spawn('python', ['manage.py', 'runserver'], {stdio: 'inherit'});
cmd.on('close', function(code) {
console.log('runServer exited with code ' + code);
cb(code);
});
});
Maybe you could try something like this:
child_process.spawn('venv/bin/python', ['manage.py', 'runserver']);
This uses the python env but only requires one command to be executed