Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function adbInstallWithOptions (target, apk, opts) {
events.emit('verbose', 'Installing apk ' + apk + ' on ' + target + '...');
var command = 'adb -s ' + target + ' install -r "' + apk + '"';
return Q.promise(function (resolve, reject) {
child_process.exec(command, opts, function (err, stdout, stderr) {
if (err) reject(new CordovaError('Error executing "' + command + '": ' + stderr));
// adb does not return an error code even if installation fails. Instead it puts a specific
// message to stdout, so we have to use RegExp matching to detect installation failure.
else if (/Failure/.test(stdout)) {
if (stdout.match(/INSTALL_PARSE_FAILED_NO_CERTIFICATES/)) {
stdout += 'Sign the build using \'-- --keystore\' or \'--buildConfig\'' +
' or sign and deploy the unsigned apk manually using Android tools.';
} else if (stdout.match(/INSTALL_FAILED_VERSION_DOWNGRADE/)) {
stdout += 'You\'re trying to install apk with a lower versionCode that is already installed.' +
'\nEither uninstall an app or increment the versionCode.';
}
reject(new CordovaError('Failed to install apk to emulator: ' + stdout));
} else resolve(stdout);
});
function adbInstallWithOptions (target, apk, opts) {
events.emit('verbose', 'Installing apk ' + apk + ' on ' + target + '...');
var command = 'adb -s ' + target + ' install -r "' + apk + '"';
return Q.promise(function (resolve, reject) {
child_process.exec(command, opts, function (err, stdout, stderr) {
if (err) reject(new CordovaError('Error executing "' + command + '": ' + stderr));
// adb does not return an error code even if installation fails. Instead it puts a specific
// message to stdout, so we have to use RegExp matching to detect installation failure.
else if (/Failure/.test(stdout)) {
if (stdout.match(/INSTALL_PARSE_FAILED_NO_CERTIFICATES/)) {
stdout += 'Sign the build using \'-- --keystore\' or \'--buildConfig\'' +
' or sign and deploy the unsigned apk manually using Android tools.';
} else if (stdout.match(/INSTALL_FAILED_VERSION_DOWNGRADE/)) {
stdout += 'You\'re trying to install apk with a lower versionCode that is already installed.' +
'\nEither uninstall an app or increment the versionCode.';
}
reject(new CordovaError('Failed to install apk to emulator: ' + stdout));
} else resolve(stdout);
});
updateCanvasDims() {
return Q.promise((resolve) => {
// Updates width of $canvas to take scrollbar of $scrollingParent into account
// this.$canvas.width(this.$scrollingChild.width());
var width = this.$canvas[0].scrollWidth,
height = this.$canvas[0].scrollHeight;
this.layoutSettings.canvasDims.width = width;
this.layoutSettings.canvasDims.height = height;
this.artist.setDimensions(width, height);
resolve();
});
}
setup: function(contractSrc) {
contractSrc = ''+contractSrc;
var tokens = [];
var argPs = [];
var resolve;
var resultP = Q.promise(function(r) { resolve = r; });
console.log(contractSrc);
var contract = confine(contractSrc, {Q: Q});
var addParam = function(i, token) {
tokens[i] = token;
var resolveArg;
argPs[i] = Q.promise(function(r) { resolveArg = r; });
m.set(token, function(allegedSrc, allegedI, arg) {
if (contractSrc !== allegedSrc) {
throw new Error('unexpected contract: '+contractSrc);
}
if (i !== allegedI) {
throw new Error('unexpected side: '+i);
}
m.delete(token);
resolveArg(arg);
connect(c) {
this.config = Object.assign(this.config, c);
++this.__retries;
if (this.__$connectPromise != null)
return this.__$connectPromise;
this.__$connectPromise = Q.promise((resolve, reject, notify) => {
this.emit(SSHConstants.CHANNEL.SSH, SSHConstants.STATUS.BEFORECONNECT);
if (!this.config || typeof this.config === 'function' || !this.config.host || !this.config.username) {
reject("Invalid SSH connection configuration host/username can't be empty");
this.__$connectPromise = null;
return;
}
if (this.config.tryKeyboard && !this.config.password && typeof this.config !== 'undefined') {
delete this.config.password;
}
if (this.config.identity) {
if (fs.existsSync(this.config.identity)) {
this.config.privateKey = fs.readFileSync(this.config.identity);
}
delete this.config.identity;
function checkFileExists(file){
return Q.promise(function (resolve) {
fs.exists(file, resolve);
});
}
_downloadCover: function(url, output) {
var file = fs.createWriteStream(output);
var promise = Q.promise(function(resolve, reject) {
httpFollower.get(url, function followRedirects(res) {
res.pipe(file);
res.on('end', function() {
resolve(file);
});
file.on('error', reject);
res.on('error', reject);
});
});
return promise;
},
var readFromReadData = function(file) {
return Q.promise(function(resolve, reject) {
file.readData(function(str) {
resolve({name: file.name, content: str})
}, function() {
reject(file.name);
});
});
};
connect(c) {
this.config = Object.assign(this.config, c);
++this.__retries;
if (this.__$connectPromise != null)
return this.__$connectPromise;
this.__$connectPromise = Q.promise((resolve, reject, notify) => {
if (!this.config || typeof this.config === 'function' || !this.config.host || !this.config.username) {
reject("Invalid SSH connection configuration host/username can't be empty");
this.__$connectPromise = null;
return;
}
if (this.config.tryKeyboard && !this.config.password && typeof this.config !== 'undefined') {
delete this.config.password;
}
if (this.config.identity) {
if (fs.existsSync(this.config.identity)) {
this.config.privateKey = fs.readFileSync(this.config.identity);
}
delete this.config.identity;
}
goals.forEach(function (goal) {
var achieve = goal.__progress >= 100;
if (achieve) {
var promise = Q.promise(function (resolve, reject) {
GoalAchievement.find({goalId: goal._id, date: date}, function (err, achieve) {
if (err) {
return reject(err);
}
resolve({goal: goal, achieve: achieve[0]});
});
});
promises.push(promise);
}
});
return Q.all(promises);