Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
benmonro committed Mar 29, 2013
1 parent aba4fe8 commit 969f4bc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -35,7 +35,7 @@ Installing an APK
-----------------

```javascript
adb.installApk("/path/to/my.apk", function() {
adb.install("/path/to/my.apk", function() {
//do cool stuff
});
```
Expand Down
12 changes: 9 additions & 3 deletions android.js
Expand Up @@ -3,14 +3,17 @@ var exec = require('child_process').exec;

exports.isInstalled = function (pattern, isInstalledCallback) {

var isInstalledCommand = "adb shell ls /data/app/" + pattern; //com.zonarsystems.mockvehicledeviceinfo*";
var isInstalledCommand = "adb shell pm list packages| grep package:" + pattern;
console.log(isInstalledCommand);
exec(isInstalledCommand, function (err, stdout, stderr) {
isInstalledCallback(stdout.indexOf("No such file or directory") === -1);
console.log("result:\n" + stdout);

isInstalledCallback(stdout.indexOf(pattern) >= 0);
});

}

exports.installApk = function (pathToApk, completedCallback) {
exports.install = function (pathToApk, completedCallback) {


sys.print("installing " + pathToApk);
Expand All @@ -30,9 +33,12 @@ exports.firstDevice = function (callback) {
var findDeviceId = /\n([\d\w]+)\s+/m;
var match = findDeviceId.exec(stdout);

console.log("adb devices:\n" + stdout);

if (match != null) {
callback(match[1]);
} else {
callback();
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "android",
"version": "0.0.5",
"version": "0.0.6",
"description": "various android utils & commands for node",
"main": "android.js",
"scripts": {
Expand Down

0 comments on commit 969f4bc

Please sign in to comment.