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

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

var env = require('yeoman-generator')();

var workingDirectory = //Path where generator should be executed. generator = env.create('iosapp:app'); generator.destinationRoot(workingDirectory);
generator.run();

Generator ID for create call you will be able to find by calling yo without arguments.