Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

refactoring windows scripts

  • Loading branch information...
commit 68161d2714c9d966139f3c9fe485b582884939c3 1 parent a6473cb
@imhotep imhotep authored macdonst committed
Showing with 33 additions and 18 deletions.
  1. +2 −3 bin/create.js
  2. +31 −15 bin/templates/cordova/cordova.js
View
5 bin/create.js
@@ -198,10 +198,9 @@ exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\appinfo.jar ' + PRO
exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\cordova.js ' + PROJECT_PATH + '\\cordova\\cordova.js /Y');
exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\cordova.bat ' + PROJECT_PATH + '\\cordova\\cordova.bat /Y');
exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\clean.bat ' + PROJECT_PATH + '\\cordova\\clean.bat /Y');
-exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\debug.bat ' + PROJECT_PATH + '\\cordova\\debug.bat /Y');
+exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\build.bat ' + PROJECT_PATH + '\\cordova\\build.bat /Y');
exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\log.bat ' + PROJECT_PATH + '\\cordova\\log.bat /Y');
-exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\emulate.bat ' + PROJECT_PATH + '\\cordova\\emulate.bat /Y');
-exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\BOOM.bat ' + PROJECT_PATH + '\\cordova\\BOOM.bat /Y');
+exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\run.bat ' + PROJECT_PATH + '\\cordova\\run.bat /Y');
// interpolate the activity name and package
WScript.Echo("Updating AndroidManifest.xml and Main Activity...");
View
46 bin/templates/cordova/cordova.js
@@ -34,17 +34,19 @@ function exec(command) {
return output;
}
-function emulator_running() {
+function device_running() {
var local_devices = shell.Exec("%comspec% /c adb devices").StdOut.ReadAll();
- if(local_devices.match(/emulator/)) {
+ if(local_devices.match(/\w+\tdevice/)) {
+ WScript.Echo("Yes");
return true;
}
+ WScript.Echo("No");
return false;
}
function emulate() {
// don't run emulator if a device is plugged in or if emulator is already running
- if(emulator_running()) {
- WScript.Echo("Device or Emulator already running!");
+ if(device_running()) {
+ //WScript.Echo("Device or Emulator already running!");
return;
}
var oExec = shell.Exec("%comspec% /c android.bat list avd");
@@ -84,18 +86,18 @@ function emulate() {
}
function clean() {
+ WScript.Echo("Cleaning project...");
exec("%comspec% /c ant.bat clean -f "+ROOT+"\\build.xml 2>&1");
}
-function debug() {
- if(emulator_running()) {
- exec("%comspec% /c ant.bat debug install -f "+ROOT+"\\build.xml 2>&1");
- } else {
- exec("%comspec% /c ant.bat debug -f "+ROOT+"\\build.xml 2>&1");
- WScript.Echo("##################################################################");
- WScript.Echo("# Plug in your device or launch an emulator with cordova/emulate #");
- WScript.Echo("##################################################################");
- }
+function build() {
+ WScript.Echo("Building project...");
+ exec("%comspec% /c ant.bat debug -f "+ROOT+"\\build.xml 2>&1");
+}
+
+function install() {
+ WScript.Echo("Building/Installing project...");
+ exec("%comspec% /c ant.bat debug install -f "+ROOT+"\\build.xml 2>&1");
}
function log() {
@@ -103,14 +105,28 @@ function log() {
}
function launch() {
+ WScript.Echo("Launching app...");
var launch_str=exec("%comspec% /c java -jar "+ROOT+"\\cordova\\appinfo.jar "+ROOT+"\\AndroidManifest.xml");
//WScript.Echo(launch_str);
exec("%comspec% /c adb shell am start -n "+launch_str+" 2>&1");
}
-function BOOM() {
+function run() {
+ var i=0;
clean();
- debug();
+ emulate();
+ WScript.Stdout.Write('Waiting for device...');
+ while(!device_running() && i < 300) {
+ WScript.Stdout.Write('.');
+ WScript.sleep(1000);
+ i += 1;
+ }
+ if(i == 300) {
+ WScript.Stderr.WriteLine("device/emulator timeout!");
+ } else {
+ WScript.Stdout.WriteLine("connected!");
+ }
+ install();
launch();
}
var args = WScript.Arguments;
Please sign in to comment.
Something went wrong with that request. Please try again.