var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.PIPES=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));

var _shelljs=_interopRequireDefault(require("shelljs"));
var _chalk=_interopRequireDefault(require("chalk"));
var _open=_interopRequireDefault(require("open"));
var _ip=_interopRequireDefault(require("ip"));
var _path=_interopRequireDefault(require("path"));

var _common=require("../common");
















var _constants=require("../constants");

















var _apple=require("../platformTools/apple");







var _web=require("../platformTools/web");
var _tizen=require("../platformTools/tizen");
var _webos=require("../platformTools/webos");
var _firefox=require("../platformTools/firefox");
var _electron=require("../platformTools/electron");



var _setupTools=_interopRequireDefault(require("../setupTools"));
var _buildHooks=require("../projectTools/buildHooks");
var _projectParser=require("../projectTools/projectParser");
var _android=require("../platformTools/android");






var _fileutils=require("../systemTools/fileutils");

var RUN='run';
var LOG='log';
var START='start';
var PACKAGE='package';
var BUILD='build';
var DEPLOY='deploy';
var EXPORT='export';
var TEST='test';
var DOC='doc';
var UNINSTALL='uninstall';
var FIX='fix';
var DEBUG='debug';

var PIPES={
RUN_BEFORE:'run:before',
RUN_AFTER:'run:after',
LOG_BEFORE:'log:before',
LOG_AFTER:'log:after',
START_BEFORE:'start:before',
START_AFTER:'start:after',
PACKAGE_BEFORE:'package:before',
PACKAGE_AFTER:'package:after',
EXPORT_BEFORE:'export:before',
EXPORT_AFTER:'export:after',
BUILD_BEFORE:'build:before',
BUILD_AFTER:'build:after',
DEPLOY_BEFORE:'deploy:before',
DEPLOY_AFTER:'deploy:after'};exports.PIPES=PIPES;


var isRunningOnWindows=process.platform==='win32';





var run=function run(c){
(0,_common.logTask)('run');

switch(c.command){
case START:
return _startServer(c);
case RUN:
return _runApp(c);
case PACKAGE:
return _packageApp(c);
case BUILD:
return _buildApp(c);
case EXPORT:
return _exportApp(c);
case DEPLOY:
return _deployApp(c);
case LOG:
return _log(c);
case FIX:
return _fix(c);
case DEBUG:
return _debug(c);









default:
return Promise.reject("cli:runner: Command "+c.command+" not supported");}

};





var _fix=function _fix(c){return new Promise(function(resolve,reject){
(0,_projectParser.cleanNodeModules)(c).then(function(){return resolve();}).catch(function(e){return reject(e);});
});};

var _isWebHostEnabled=function _isWebHostEnabled(c,platform){var
hosted=c.program.hosted;
var bundleAssets=(0,_common.getConfigProp)(c,platform,'bundleAssets');
return(hosted||!bundleAssets)&&_constants.WEB_HOSTED_PLATFORMS.includes(platform);
};

var _startServer=function _startServer(c){return new Promise(function(resolve,reject){var
platform=c.platform;
var port=c.program.port||c.platformDefaults[platform]?c.platformDefaults[platform].defaultPort:null;var
hosted=c.program.hosted;

(0,_common.logTask)("_startServer:"+platform+":"+port);

if(_isWebHostEnabled(c,platform)&&hosted){
var hostIp=isRunningOnWindows?'127.0.0.1':'0.0.0.0';
(0,_common.waitForWebpack)(port).
then(function(){return(0,_open.default)("http://"+hostIp+":"+port+"/");}).
catch(_common.logError);
}

switch(platform){
case _constants.MACOS:
case _constants.WINDOWS:
(0,_buildHooks.executePipe)(c,PIPES.START_BEFORE).
then(function(){return(0,_electron.runElectronDevServer)(c,platform,port);}).
then(function(){return(0,_buildHooks.executePipe)(c,PIPES.START_AFTER);}).
then(function(){return resolve();}).
catch(function(e){return reject(e);});
return;
case _constants.WEB:
case _constants.TIZEN:
case _constants.WEBOS:
case _constants.TIZEN_MOBILE:
case _constants.TIZEN_WATCH:
(0,_buildHooks.executePipe)(c,PIPES.START_BEFORE).
then(function(){return(0,_common.configureIfRequired)(c,platform);}).
then(function(){return(0,_web.runWebDevServer)(c,platform,port);}).
then(function(){return(0,_buildHooks.executePipe)(c,PIPES.START_AFTER);}).
then(function(){return resolve();}).
catch(function(e){return reject(e);});
return;
default:
if(hosted){
return(0,_common.logError)('This platform does not support hosted mode',true);
}}


var startCmd;
if(c.program.reset){
startCmd='node ./node_modules/react-native/local-cli/cli.js start --reset-cache';
}else{
startCmd='node ./node_modules/react-native/local-cli/cli.js start';
}

(0,_buildHooks.executePipe)(c,PIPES.START_BEFORE).
then(function(){
_shelljs.default.exec(startCmd);
}).
catch(function(e){return reject(e);});
});};

var runWeinre=function runWeinre(){
_shelljs.default.exec('npx weinre --boundHost -all-');
};

var _debug=function _debug(c){return(0,_buildHooks.executePipe)(c,PIPES.START_BEFORE).
then(function(){return runWeinre();}).
then(function(){return(0,_buildHooks.executePipe)(c,PIPES.START_AFTER);});};


var _runApp=function _runApp(c){return new Promise(function(resolve,reject){
(0,_common.logTask)("_runApp:"+c.platform);

(0,_common.isPlatformSupported)(c).
then(function(){return(0,_common.isBuildSchemeSupported)(c);}).
then(function(){return _runAppWithPlatform(c);}).
then(function(){return resolve();}).
catch(function(e){return reject(e);});
});};

var _packageApp=function _packageApp(c){return new Promise(function(resolve,reject){
(0,_common.logTask)("_packageApp:"+c.platform);

(0,_common.isPlatformSupported)(c).
then(function(){return(0,_common.isBuildSchemeSupported)(c);}).
then(function(){return _packageAppWithPlatform(c);}).
then(function(){return resolve();}).
catch(function(e){return reject(e);});
});};

var _buildApp=function _buildApp(c){return new Promise(function(resolve,reject){
(0,_common.logTask)("_buildApp:"+c.platform);

(0,_common.isPlatformSupported)(c).
then(function(){return(0,_common.isBuildSchemeSupported)(c);}).
then(function(){return _buildAppWithPlatform(c);}).
then(function(){return resolve();}).
catch(function(e){return reject(e);});
});};

var _exportApp=function _exportApp(c){return new Promise(function(resolve,reject){
(0,_common.logTask)("_exportApp:"+c.platform);

(0,_common.isPlatformSupported)(c).
then(function(){return(0,_common.isBuildSchemeSupported)(c);}).
then(function(){return _exportAppWithPlatform(c);}).
then(function(){return resolve();}).
catch(function(e){return reject(e);});
});};

var _deployApp=function _deployApp(c){return new Promise(function(resolve,reject){
(0,_common.logTask)("_deployApp:"+c.platform);

(0,_common.isPlatformSupported)(c).
then(function(){return(0,_common.isBuildSchemeSupported)(c);}).
then(function(){return _deployAppWithPlatform(c);}).
then(function(){return resolve();}).
catch(function(e){return reject(e);});
});};

var configureHostedIfRequired=function configureHostedIfRequired(c,platform){var _c$paths,project,rnv;return _regenerator.default.async(function configureHostedIfRequired$(_context){while(1){switch(_context.prev=_context.next){case 0:
if(_isWebHostEnabled(c,platform)){
(0,_common.logDebug)('Running hosted build');_c$paths=
c.paths,project=_c$paths.project,rnv=_c$paths.rnv;
(0,_fileutils.copyFolderContentsRecursiveSync)(_path.default.join(rnv.dir,'supportFiles','appShell'),_path.default.join(project.dir,'platformBuilds',c.runtime.appId+"_"+platform,'public'));
(0,_common.writeCleanFile)(_path.default.join(rnv.dir,'supportFiles','appShell','index.html'),_path.default.join(project.dir,'platformBuilds',c.runtime.appId+"_"+platform,'public','index.html'),[
{pattern:'{{DEV_SERVER}}',override:"http://"+_ip.default.address()+":"+c.platformDefaults[platform].defaultPort}]);

}case 1:case"end":return _context.stop();}}});};


var startHostedServerIfRequired=function startHostedServerIfRequired(c,platform){
if(_isWebHostEnabled(c,platform)){
return _startServer(c);
}
};

var _runAppWithPlatform=function _runAppWithPlatform(c){var platform,port,target,_c$program,device,hosted,throwErr,setupInstance,_setupInstance,_setupInstance2;return _regenerator.default.async(function _runAppWithPlatform$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:
(0,_common.logTask)("_runAppWithPlatform:"+c.platform);
platform=c.platform;
port=c.program.port||c.platformDefaults[platform].defaultPort;
target=c.program.target||c.files.private.config.defaultTargets[platform];_c$program=
c.program,device=_c$program.device,hosted=_c$program.hosted;

(0,_common.logTask)("_runAppWithPlatform:"+platform+":"+port+":"+target,_chalk.default.grey);

throwErr=function throwErr(err){
throw err;
};if(!(

_isWebHostEnabled(c,platform)&&hosted)){_context2.next=9;break;}return _context2.abrupt("return",
_startServer(c));case 9:_context2.t0=



platform;_context2.next=_context2.t0===
_constants.IOS?12:_context2.t0===
_constants.TVOS?12:_context2.t0===





_constants.ANDROID?13:_context2.t0===
_constants.ANDROID_TV?13:_context2.t0===
_constants.ANDROID_WEAR?13:_context2.t0===











_constants.MACOS?28:_context2.t0===
_constants.WINDOWS?28:_context2.t0===





_constants.WEB?29:_context2.t0===





_constants.TIZEN?30:_context2.t0===
_constants.TIZEN_MOBILE?30:_context2.t0===
_constants.TIZEN_WATCH?30:_context2.t0===












_constants.WEBOS?35:_context2.t0===












_constants.KAIOS?40:_context2.t0===
_constants.FIREFOX_OS?40:_context2.t0===
_constants.FIREFOX_TV?40:43;break;case 12:return _context2.abrupt("return",(0,_buildHooks.executePipe)(c,PIPES.RUN_BEFORE).then(function(){return(0,_common.cleanPlatformIfRequired)(c,platform);}).then(function(){return(0,_common.configureIfRequired)(c,platform);}).then(function(){return(0,_apple.runXcodeProject)(c,platform,target);}).then(function(){return(0,_buildHooks.executePipe)(c,PIPES.RUN_AFTER);}));case 13:if((0,_common.checkSdk)(c,platform,_common.logError)){_context2.next=17;break;}setupInstance=(0,_setupTools.default)(c);_context2.next=17;return _regenerator.default.awrap(setupInstance.askToInstallSDK('android'));case 17:_context2.next=19;return _regenerator.default.awrap((0,_buildHooks.executePipe)(c,PIPES.RUN_BEFORE));case 19:_context2.next=21;return _regenerator.default.awrap((0,_common.cleanPlatformIfRequired)(c,platform));case 21:_context2.next=23;return _regenerator.default.awrap((0,_common.configureIfRequired)(c,platform));case 23:_context2.next=25;return _regenerator.default.awrap(_runAndroid(c,platform,target,platform===_constants.ANDROID_WEAR));case 25:_context2.next=27;return _regenerator.default.awrap((0,_buildHooks.executePipe)(c,PIPES.RUN_AFTER));case 27:return _context2.abrupt("return");case 28:return _context2.abrupt("return",(0,_buildHooks.executePipe)(c,PIPES.RUN_BEFORE).then(function(){return(0,_common.cleanPlatformIfRequired)(c,platform);}).then(function(){return(0,_common.configureIfRequired)(c,platform);}).then(function(){return(0,_electron.runElectron)(c,platform,port);}).then(function(){return(0,_buildHooks.executePipe)(c,PIPES.RUN_AFTER);}));case 29:return _context2.abrupt("return",(0,_buildHooks.executePipe)(c,PIPES.RUN_BEFORE).then(function(){return(0,_common.cleanPlatformIfRequired)(c,platform);}).then(function(){return(0,_common.configureIfRequired)(c,platform);}).then(function(){return(0,_web.runWeb)(c,platform,port);}).then(function(){return(0,_buildHooks.executePipe)(c,PIPES.RUN_AFTER);}));case 30:if((0,_common.checkSdk)(c,platform,_common.logError)){_context2.next=34;break;}_setupInstance=(0,_setupTools.default)(c);_context2.next=34;return _regenerator.default.awrap(_setupInstance.askToInstallSDK('tizen'));case 34:return _context2.abrupt("return",(0,_buildHooks.executePipe)(c,PIPES.RUN_BEFORE).then(function(){return(0,_common.cleanPlatformIfRequired)(c,platform);}).then(function(){return(0,_common.configureIfRequired)(c,platform);}).then(function(){return configureHostedIfRequired(c,platform);}).then(function(){return(0,_tizen.runTizen)(c,platform,target);}).then(function(){return(0,_buildHooks.executePipe)(c,PIPES.RUN_AFTER);}).then(function(){return startHostedServerIfRequired(c,platform);}));case 35:if((0,_common.checkSdk)(c,platform,_common.logError)){_context2.next=39;break;}_setupInstance2=(0,_setupTools.default)(c);_context2.next=39;return _regenerator.default.awrap(_setupInstance2.askToInstallSDK('webos'));case 39:return _context2.abrupt("return",(0,_buildHooks.executePipe)(c,PIPES.RUN_BEFORE).then(function(){return(0,_common.cleanPlatformIfRequired)(c,platform);}).then(function(){return(0,_common.configureIfRequired)(c,platform);}).then(function(){return configureHostedIfRequired(c,platform);}).then(function(){return(0,_webos.runWebOS)(c,platform,target);}).then(function(){return(0,_buildHooks.executePipe)(c,PIPES.RUN_AFTER);}).then(function(){return startHostedServerIfRequired(c,platform);}));case 40:if(!(
platform===_constants.KAIOS&&!(0,_common.checkSdk)(c,platform,throwErr))){_context2.next=42;break;}return _context2.abrupt("return");case 42:return _context2.abrupt("return",

(0,_buildHooks.executePipe)(c,PIPES.RUN_BEFORE).
then(function(){return(0,_common.cleanPlatformIfRequired)(c,platform);}).
then(function(){return(0,_common.configureIfRequired)(c,platform);}).
then(function(){return(0,_firefox.runFirefoxProject)(c,platform);}).
then(function(){return(0,_buildHooks.executePipe)(c,PIPES.RUN_AFTER);}));case 43:return _context2.abrupt("break",44);case 44:return _context2.abrupt("return",




(0,_common.logErrorPlatform)(platform));case 45:case"end":return _context2.stop();}}});};


var _packageAppWithPlatform=function _packageAppWithPlatform(c){return new Promise(function(resolve,reject){
(0,_common.logTask)("_packageAppWithPlatform:"+c.platform);var
platform=c.platform;

var target=c.program.target||c.files.private.config.defaultTargets[platform];

switch(platform){
case _constants.IOS:
case _constants.TVOS:
(0,_buildHooks.executePipe)(c,PIPES.PACKAGE_BEFORE).
then(function(){return(0,_common.cleanPlatformIfRequired)(c,platform);}).
then(function(){return(0,_common.configureIfRequired)(c,platform);}).
then(function(){return(0,_apple.packageBundleForXcode)(c,platform);}).
then(function(){return(0,_buildHooks.executePipe)(c,PIPES.PACKAGE_AFTER);}).
then(function(){return resolve();}).
catch(function(e){return reject(e);});
return;
case _constants.ANDROID:
case _constants.ANDROID_TV:
case _constants.ANDROID_WEAR:
if(!(0,_common.checkSdk)(c,platform,reject))return;

(0,_buildHooks.executePipe)(c,PIPES.PACKAGE_BEFORE).
then(function(){return(0,_common.cleanPlatformIfRequired)(c,platform);}).
then(function(){return(0,_common.configureIfRequired)(c,platform);}).
then(function(){return(0,_android.configureGradleProject)(c,platform);}).
then(function(){return(0,_android.packageAndroid)(c,platform,target,platform===_constants.ANDROID_WEAR);}).
then(function(){return(0,_buildHooks.executePipe)(c,PIPES.PACKAGE_AFTER);}).
then(function(){return resolve();}).
catch(function(e){return reject(e);});
return;}


(0,_common.logErrorPlatform)(platform,resolve);
});};

var _exportAppWithPlatform=function _exportAppWithPlatform(c){return new Promise(function(resolve,reject){
(0,_common.logTask)("_exportAppWithPlatform:"+c.platform);var
platform=c.platform;
switch(platform){
case _constants.IOS:
case _constants.TVOS:
(0,_buildHooks.executePipe)(c,PIPES.EXPORT_BEFORE).
then(function(){return c.program.only?Promise.resolve():_buildAppWithPlatform(c,platform);}).
then(function(){return(0,_apple.exportXcodeProject)(c,platform);}).
then(function(){return(0,_buildHooks.executePipe)(c,PIPES.EXPORT_AFTER);}).
then(function(){return resolve();}).
catch(function(e){return reject(e);});
return;
case _constants.MACOS:
case _constants.WINDOWS:
(0,_buildHooks.executePipe)(c,PIPES.EXPORT_BEFORE).
then(function(){return(0,_common.cleanPlatformIfRequired)(c,platform);}).
then(function(){return(0,_common.configureIfRequired)(c,platform);}).
then(function(){return(0,_electron.configureElectronProject)(c,platform);}).
then(function(){return(0,_electron.buildElectron)(c,platform);}).
then(function(){return(0,_electron.exportElectron)(c,platform);}).
then(function(){return(0,_buildHooks.executePipe)(c,PIPES.EXPORT_AFTER);}).
then(function(){return resolve();}).
catch(function(e){return reject(e);});
return;}


(0,_common.logErrorPlatform)(platform,resolve);
});};

var _deployAppWithPlatform=function _deployAppWithPlatform(c){return new Promise(function(resolve,reject){
(0,_common.logTask)("_deployAppWithPlatform:"+c.platform);var
platform=c.platform;

switch(platform){
case _constants.WEB:
(0,_buildHooks.executePipe)(c,PIPES.DEPLOY_BEFORE).
then(function(){return c.program.only?Promise.resolve():_buildApp(c);}).
then(function(){return(0,_web.deployWeb)(c,platform);}).
then(function(){return(0,_buildHooks.executePipe)(c,PIPES.DEPLOY_AFTER);}).
then(function(){return resolve();}).
catch(function(e){return reject(e);});
return;
case _constants.IOS:
(0,_buildHooks.executePipe)(c,PIPES.DEPLOY_BEFORE).
then(function(v){return c.program.only?Promise.resolve():_exportAppWithPlatform(c);}).
then(function(){return(0,_buildHooks.executePipe)(c,PIPES.DEPLOY_AFTER);}).
then(function(){return resolve();}).
catch(function(e){return reject(e);});
return;
case _constants.ANDROID:
(0,_buildHooks.executePipe)(c,PIPES.DEPLOY_BEFORE).
then(function(v){return c.program.only?Promise.resolve():_buildAppWithPlatform(c);}).
then(function(){return(0,_buildHooks.executePipe)(c,PIPES.DEPLOY_AFTER);}).
then(function(){return resolve();}).
catch(function(e){return reject(e);});
return;}


(0,_common.logErrorPlatform)(platform,resolve);
});};

var _buildAppWithPlatform=function _buildAppWithPlatform(c){return new Promise(function(resolve,reject){
(0,_common.logTask)("_buildAppWithPlatform:"+c.platform);var
platform=c.platform;

switch(platform){
case _constants.ANDROID:
case _constants.ANDROID_TV:
case _constants.ANDROID_WEAR:
(0,_buildHooks.executePipe)(c,PIPES.BUILD_BEFORE).
then(function(){return(0,_common.cleanPlatformIfRequired)(c,platform);}).
then(function(){return(0,_common.configureIfRequired)(c,platform);}).
then(function(){return(0,_android.configureGradleProject)(c,platform);}).
then(function(){return(0,_android.packageAndroid)(c,platform);}).
then(function(){return(0,_android.buildAndroid)(c,platform);}).
then(function(){return(0,_buildHooks.executePipe)(c,PIPES.BUILD_AFTER);}).
then(function(){return resolve();}).
catch(function(e){return reject(e);});
return;
case _constants.MACOS:
case _constants.WINDOWS:
(0,_buildHooks.executePipe)(c,PIPES.RUN_BEFORE).
then(function(){return(0,_common.cleanPlatformIfRequired)(c,platform);}).
then(function(){return(0,_common.configureIfRequired)(c,platform);}).
then(function(){return(0,_electron.configureElectronProject)(c,platform);}).
then(function(){return(0,_electron.buildElectron)(c,platform);}).
then(function(){return(0,_buildHooks.executePipe)(c,PIPES.RUN_AFTER);}).
then(function(){return resolve();}).
catch(function(e){return reject(e);});
return;
case _constants.IOS:
case _constants.TVOS:
(0,_buildHooks.executePipe)(c,PIPES.BUILD_BEFORE).
then(function(){return c.program.only?Promise.resolve():_packageAppWithPlatform(c,platform);}).
then(function(){return(0,_apple.archiveXcodeProject)(c,platform);}).
then(function(){return(0,_buildHooks.executePipe)(c,PIPES.BUILD_AFTER);}).
then(function(){return resolve();}).
catch(function(e){return reject(e);});
return;
case _constants.WEB:
(0,_buildHooks.executePipe)(c,PIPES.BUILD_BEFORE).
then(function(){return(0,_common.cleanPlatformIfRequired)(c,platform);}).
then(function(){return(0,_common.configureIfRequired)(c,platform);}).
then(function(){return(0,_web.buildWeb)(c,platform);}).
then(function(){return(0,_buildHooks.executePipe)(c,PIPES.BUILD_AFTER);}).
then(function(){return resolve();}).
catch(function(e){return reject(e);});
return;
case _constants.KAIOS:
case _constants.FIREFOX_OS:
case _constants.FIREFOX_TV:
(0,_buildHooks.executePipe)(c,PIPES.BUILD_BEFORE).
then(function(){return(0,_common.cleanPlatformIfRequired)(c,platform);}).
then(function(){return(0,_common.configureIfRequired)(c,platform);}).
then(function(){return(0,_firefox.buildFirefoxProject)(c,platform);}).
then(function(){return(0,_buildHooks.executePipe)(c,PIPES.BUILD_AFTER);}).
then(function(){return resolve();}).
catch(function(e){return reject(e);});
return;
case _constants.TIZEN:
case _constants.TIZEN_MOBILE:
case _constants.TIZEN_WATCH:
if(!(0,_common.checkSdk)(c,platform,reject))return;

(0,_buildHooks.executePipe)(c,PIPES.BUILD_BEFORE).
then(function(){return(0,_common.cleanPlatformIfRequired)(c,platform);}).
then(function(){return(0,_common.configureIfRequired)(c,platform);}).
then(function(){return(0,_tizen.buildTizenProject)(c,platform);}).
then(function(){return(0,_buildHooks.executePipe)(c,PIPES.BUILD_AFTER);}).
then(function(){return resolve();}).
catch(function(e){return reject(e);});
return;
case _constants.WEBOS:
if(!(0,_common.checkSdk)(c,platform,reject))return;

(0,_buildHooks.executePipe)(c,PIPES.BUILD_BEFORE).
then(function(){return(0,_common.cleanPlatformIfRequired)(c,platform);}).
then(function(){return(0,_common.configureIfRequired)(c,platform);}).
then(function(){return(0,_webos.buildWebOSProject)(c,platform);}).
then(function(){return(0,_buildHooks.executePipe)(c,PIPES.BUILD_AFTER);}).
then(function(){return resolve();}).
catch(function(e){return reject(e);});
return;}


(0,_common.logErrorPlatform)(platform,resolve);
});};

var _log=function _log(c){return new Promise(function(resolve,reject){
(0,_common.logTask)('_log');var
platform=c.platform;
if(!(0,_common.isPlatformSupportedSync)(platform,null,reject))return;

switch(platform){
case _constants.IOS:
case _constants.TVOS:
(0,_apple.runAppleLog)(c,platform).
then(function(){return resolve();}).
catch(function(e){return reject(e);});
return;
case _constants.ANDROID:
case _constants.ANDROID_TV:
case _constants.ANDROID_WEAR:
(0,_android.runAndroidLog)(c,platform).
then(function(){return resolve();}).
catch(function(e){return reject(e);});
return;}


(0,_common.logErrorPlatform)(platform,resolve);
});};

var _runAndroid=function _runAndroid(c,platform,target,forcePackage){return new Promise(function(resolve,reject){
(0,_common.logTask)("_runAndroid:"+platform);

if(c.buildConfig.platforms[platform].runScheme==='Release'||forcePackage){
(0,_android.packageAndroid)(c,platform).then(function(){
(0,_android.runAndroid)(c,platform,target).
then(function(){return resolve();}).
catch(function(e){return reject(e);});
});
}else{
(0,_android.runAndroid)(c,platform,target).
then(function(){return resolve();}).
catch(function(e){return reject(e);});
}
});};var _default=



run;exports.default=_default;