Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
74
gaia/apps/verticalhome/test/marionette/server/cli.js
Executable file
74
gaia/apps/verticalhome/test/marionette/server/cli.js
Executable file
|
|
@ -0,0 +1,74 @@
|
|||
/* global process, __dirname */
|
||||
'use strict';
|
||||
|
||||
// server cli stuff
|
||||
var fork = require('child_process').fork;
|
||||
var fs = require('fs');
|
||||
var fsPath = require('path');
|
||||
|
||||
function exit() {
|
||||
console.error();
|
||||
console.error.apply(console, arguments);
|
||||
commandHelp(console.error);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
function commandHelp(log) {
|
||||
log = log || console.log;
|
||||
|
||||
log();
|
||||
log(' App server cli');
|
||||
log();
|
||||
log(' Comamnds: ');
|
||||
log();
|
||||
log(' help - Your looking at it');
|
||||
log(' interactive <directory> [port] - ' +
|
||||
'Begin an interactive session with the app server');
|
||||
log();
|
||||
}
|
||||
|
||||
function commandInteractive(directory, port) {
|
||||
port = parseInt((port || 60234), 10);
|
||||
|
||||
if (!directory) {
|
||||
return exit('Directory must be given');
|
||||
}
|
||||
|
||||
directory = fsPath.resolve(directory);
|
||||
|
||||
if (!fs.existsSync(directory)) {
|
||||
return exit('Given app directory "%s" does not exist', directory);
|
||||
}
|
||||
|
||||
// start the server up
|
||||
console.log('Starting server...');
|
||||
|
||||
function onError(e) {
|
||||
exit('server process failed to start: ', e);
|
||||
}
|
||||
|
||||
var proc = fork(__dirname + '/child.js', [directory, port]);
|
||||
proc.once('error', onError);
|
||||
proc.on('message', function(msg) {
|
||||
if (msg.type !== 'started') {
|
||||
return;
|
||||
}
|
||||
proc.removeListener('error', onError);
|
||||
|
||||
var interactive = require('./cli/interactive');
|
||||
interactive(proc, 'http://localhost:' + msg.port + '/');
|
||||
});
|
||||
}
|
||||
|
||||
switch (process.argv[2]) {
|
||||
case 'interactive':
|
||||
commandInteractive(process.argv[3]);
|
||||
break;
|
||||
|
||||
case 'help':
|
||||
commandHelp();
|
||||
break;
|
||||
|
||||
default:
|
||||
commandHelp();
|
||||
}
|
||||
Loading…
Reference in a new issue