Merge pull request #1030 from tborys/remove_unziped_files

Remove *.app/*.apk/ file and Payload folder before appium starts to unzip file.
This commit is contained in:
bootstraponline
2013-08-21 11:02:14 -07:00
+20 -13
View File
@@ -103,20 +103,27 @@ exports.testZipArchive = function(zipPath, cb) {
};
exports.unzipApp = function(zipPath, appExt, cb) {
exports.unzipFile(zipPath, function(err, output) {
if (!err) {
var reg = new RegExp("inflating: (.+" + appExt + ")/?");
var match = reg.exec(output);
if (match) {
var appPath = path.resolve(path.dirname(zipPath), match[1]);
cb(null, appPath);
} else {
cb("App zip unzipped OK, but we couldn't find a .app bundle in it. " +
"Make sure your archive contains the .app package and nothing else",
null);
}
exec("find " + path.dirname(zipPath) + " -type d -name '*" + appExt + "' | xargs rm -rf " + path.dirname(zipPath) +
"/Payload*", function(error, stdout, stderr){
if (!error) {
exports.unzipFile(zipPath, function(err, output) {
if (!err) {
var reg = new RegExp("inflating: (.+" + appExt + ")/?");
var match = reg.exec(output);
if (match) {
var appPath = path.resolve(path.dirname(zipPath), match[1]);
cb(null, appPath);
} else {
cb("App zip unzipped OK, but we couldn't find a .app bundle in it. " +
"Make sure your archive contains the .app package and nothing else",
null);
}
} else {
cb(err, null);
}
});
} else {
cb(err, null);
cb(error, null);
}
});
};