Search code examples
node.jsyeoman

Call Yeoman commands from a NodeJS server


How to call a Yeoman command from a NodeJS server?

I want to make a simple client webpage which allows me to execute Yeoman commands, on the NodeJS server, such as

yeoman install angular
yeoman server

Solution

  • Add a path or a websocket command which executes this sample code:

    var spawn = require('child_process').spawn;
    var yeoman = spawn('yeoman', ['install', 'angular']);
    yeoman.stdout.on('data', function (data) {
        console.log('yeoman: ' + data);
    });
    

    Later edit: You have several options + examples here, including exec suggested in the comments: http://nodejs.org/api/child_process.html