Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
};
});
});
}
// TODO tar tar.gz tgz
}
return {
"fs": fs,
"http": http,
"path": path,
"href": baseUrl + path
};
});
} else if (/^https?:$/.test(parsed.protocol)) {
url = URL.resolve(baseUrl, url);
return Q.when(http.read(url), function (data) {
var fs = Zip(data);
return Q.when(fs, function (fs) {
return {
"fs": fs,
"http": http,
"path": "/",
"href": url + "#/"
};
});
});
} else {
throw new Error("Cannot fetch over protocol " + parsed.protocol + " (" + url + ")");
}
}
}).then(function () {
// This promise is always resolved, even if 'adb uninstall' fails to uninstall app
// or the app doesn't installed at all, so no error catching needed.
return Q.when().then(function () {
var apk_path = build.findBestApkForArchitecture(buildResults, target.arch);
var execOptions = {
cwd: os.tmpdir(),
timeout: INSTALL_COMMAND_TIMEOUT, // in milliseconds
killSignal: EXEC_KILL_SIGNAL
};
events.emit('log', 'Using apk: ' + apk_path);
events.emit('log', 'Package name: ' + pkgName);
events.emit('verbose', 'Installing app on emulator...');
// A special function to call adb install in specific environment w/ specific options.
// Introduced as a part of fix for http://issues.apache.org/jira/browse/CB-9119
// to workaround sporadic emulator hangs
function adbInstallWithOptions (target, apk, opts) {
deferred.resolve(q.fcall(function() {
return q.when()
.then(function() {
/* jshint -W071, -W074 */
options.encryptedPrimarySeed = typeof options.encryptedPrimarySeed !== "undefined" ? options.encryptedPrimarySeed : self.encryptedPrimarySeed;
options.encryptedSecret = typeof options.encryptedSecret !== "undefined" ? options.encryptedSecret : self.encryptedSecret;
if (options.secret) {
self.secret = options.secret;
}
if (options.primaryPrivateKey) {
throw new blocktrail.WalletInitError("specifying primaryPrivateKey has been deprecated");
}
if (options.primarySeed) {
self.primarySeed = options.primarySeed;
} else if (options.secret) {
return Q.when(list, function (list) {
// asynchronously remove every subtree
var done = list.reduce(function (prev, name) {
var child = self.join(path, name);
var next = self.removeTree(child);
// join next and prev
return Q.when(prev, function () {
return next;
});
});
return Q.when(done, function () {
self.removeDirectory(path);
});
});
} else {
deferred.resolve(q.fcall(function() {
return q.when()
.then(function() {
/* jshint -W071, -W074 */
options.encryptedPrimarySeed = typeof options.encryptedPrimarySeed !== "undefined" ? options.encryptedPrimarySeed : self.encryptedPrimarySeed;
options.encryptedSecret = typeof options.encryptedSecret !== "undefined" ? options.encryptedSecret : self.encryptedSecret;
if (options.secret) {
self.secret = options.secret;
}
if (options.primaryPrivateKey) {
throw new blocktrail.WalletInitError("specifying primaryPrivateKey has been deprecated");
}
if (options.primarySeed) {
self.primarySeed = options.primarySeed;
} else if (options.secret) {
*/
function createFunctionArray(arr) {
return arr.map(function (item, actualIndex) {
return function (index) {
assert.strictEqual(actualIndex, index, "Function-array call passed wrong index to callback");
return Q.when(item, function (result) { return callback(result, index); });
};
});
}
return Q.all([
//method(array, callback)
method(arrayFunc(), callback).then(resultFunc, errorFunc),
//method(callback)
Q.when(arrayFunc()).then(method(callback)).then(resultFunc, errorFunc),
//method(funcArray)
noFunctions || method(Q.when(arrayFunc(), createFunctionArray)).then(resultFunc, errorFunc),
//method()
noFunctions || Q.when(arrayFunc(), createFunctionArray).then(method).then(resultFunc, errorFunc)
]);
}
find: this.spy(function() {
return Q.when(docs)
})
}
return attenuate(path).then(function (path) {
return outer.makeTree(path.outer);
}).catch(function (error) {
throw new Error("Can't make tree " + JSON.stringify(path));
});
};
inner.removeTree = function (path) {
return attenuate(path).then(function (path) {
return outer.removeTree(path.outer);
}).catch(function (error) {
throw new Error("Can't remove tree " + JSON.stringify(path));
});
};
return Q.when(outer.canonical(root), function (_root) {
root = _root;
return inner;
});
}
credentials = null;
}
else if(credentials.length == 1) {
credentials.push('');
}
}
if(credentials) {
var findMap = {};
findMap[authenticatorModel.options.authenticatingProperty.name] = credentials[0];
findMap.accessToken = credentials[1];
return authenticatorModel.findOne(findMap);
}
if(!request.session.at) {
return Q.when(null);
}
return authenticatorModel.findOne({accessToken: request.session.at});
}
exports.join = function (values, fulfilled) {
var reasons;
var fulfillment = Q.defer();
var completion = values.reduce(function (done, value, i) {
return Q.when(done, function () {
return Q.when(value, function (value) {
values[i] = value;
}, function (reason) {
reasons = reasons || [];
reasons[i] = reason;
fulfillment.reject(reason);
});
});
}, undefined);
Q.when(completion, fulfillment.resolve);
return Q.when(fulfillment.promise, function () {
return fulfilled ? fulfilled.apply(null, values) : values;
}, function () {
reasons = reasons || [];
return Q.reject({
"toString": function () {
return "Can't join. " + reasons.join("; ");
},
"reasons": Q.when(completion, function () {
return reasons;
})
});
});
};