|
| 1 | +var fs = require('fs'), |
| 2 | + os = require('os'), |
| 3 | + request = require('request'), |
| 4 | + ncp = require('ncp').ncp, |
| 5 | + path = require('path'), |
| 6 | + shelljs = require('shelljs/global'), |
| 7 | + unzip = require('unzip'), |
| 8 | + IonicTask = require('./task').IonicTask, |
| 9 | + IonicStats = require('./stats').IonicStats; |
| 10 | + |
| 11 | +var argv = require('optimist').argv; |
| 12 | + |
| 13 | +var IonicEmulateTask = function() { |
| 14 | +} |
| 15 | + |
| 16 | +IonicEmulateTask.HELP_LINE = 'Emulate an ionic project on a simulator or emulator.'; |
| 17 | + |
| 18 | +IonicEmulateTask.prototype = new IonicTask(); |
| 19 | + |
| 20 | +IonicEmulateTask.prototype._printUsage = function() { |
| 21 | + process.stderr.write('\nUsage: ionic emulate [platform]\n'); |
| 22 | +} |
| 23 | + |
| 24 | +IonicEmulateTask.prototype.run = function(ionic) { |
| 25 | + var patform; |
| 26 | + |
| 27 | + if(argv._.length < 2) { |
| 28 | + IonicEmulateTask.prototype._printUsage(); |
| 29 | + ionic.fail('No platforms specified, exiting.'); |
| 30 | + } |
| 31 | + |
| 32 | + var platforms = argv._.slice(1); |
| 33 | + |
| 34 | + if(platforms.length < 1) { |
| 35 | + ionic.fail('No platforms specified, exiting.'); |
| 36 | + } |
| 37 | + |
| 38 | + IonicStats.t('emulate', { 'platform': platforms.join(',') }); |
| 39 | + |
| 40 | + for(var i = 0; i < platforms.length; i++) { |
| 41 | + platform = platforms[i]; |
| 42 | + console.log('Emulating app on platform', platform); |
| 43 | + if(exec("cordova emulate " + platform).code !== 0) { |
| 44 | + ionic.fail('Unable to emulate app on platform ' + platform + '. Please see console for more info.'); |
| 45 | + } |
| 46 | + } |
| 47 | +}; |
| 48 | + |
| 49 | +exports.IonicEmulateTask = IonicEmulateTask; |
0 commit comments