Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const redirectTitle = mwUtil.extractRedirect(html.body) ||
// Redirect detected while saving new HTML.
html.headers.location;
if (redirectTitle) {
const newParams = Object.assign({}, rp);
newParams[titleParamName] = redirectTitle;
const location = mwUtil.createRelativeTitleRedirect(specInfo.path, req, {
newReqParams: newParams,
titleParamName,
dropPathAfterTitle: true
});
let contentPromise;
if (options.attach_body_to_redirect) {
if (specInfo.path.indexOf('html') !== -1) {
contentPromise = P.resolve(html);
} else {
contentPromise = next(hyper, req);
}
} else {
contentPromise = P.resolve({
headers: {
etag: html.headers.etag
}
});
}
return contentPromise.then((content) => redirect(content, location, options));
} else {
return next(hyper, req);
}
});
// Delete all of the *in* keys for the associations.
const asyncDeleteInSets = redis.del(keysIn);
// Remove the keys that were cleared from the *contains* keys.
const asyncRemoveContains = asyncGetContainsKeys.then(keysAllContains =>
Promise.all(
(keysAllContains || []).map(key => redis('srem', prefixContains + key, ...keys))
).then(results => ((results && results.length) ? results.reduce((a, b) => a + b) : 0))
);
let asyncKeysNextLevel;
let asyncClearNextLevel;
if (level > maxLevel) {
asyncKeysNextLevel = Promise.resolve([]);
asyncClearNextLevel = Promise.resolve();
} else {
// Get the next level of keys to clear.
asyncKeysNextLevel = redis.sunion(keysContains);
// Clear the next level of keys.
asyncClearNextLevel = asyncKeysNextLevel.then(
keysNextLevel => (keysNextLevel.length ? cacheClearLevel(keysNextLevel, level + 1) : Promise.resolve())
);
}
return Promise.props({
success: true,
everyAsync(interval, jobName, data, options) {
agendaStub.everyAsync(interval, jobName, data, options);
return Promise.resolve({});
}
cancelAsync(criteria) {
loggerWarnSpy = sinon.spy(logger, 'warn');
retryStub = sandbox.stub(utils, 'retry').callsFake((callback, options) => callback());
dbInitializeSpy = sinon.spy(DBManager.prototype, 'initialize');
dbInitializeForCreateSpy = sinon.spy(DBManagerCreateWithDelayedReconnectRetry.prototype, 'initialize');
dbInitializeByUrlSpy = sinon.spy(DBManagerByUrl.prototype, 'initialize');
dbCreateUpdateSucceededSpy = sandbox.spy(DBManagerForUpdate.prototype, 'dbCreateUpdateSucceeded');
getDeploymentVMsStub = sandbox.stub(BoshDirectorClient.prototype, 'getDeploymentVms');
getDeploymentStub = sandbox.stub(BoshDirectorClient.prototype, 'getDeployment');
pollTaskStatusTillCompleteStub = sandbox.stub(BoshDirectorClient.prototype, 'pollTaskStatusTillComplete').callsFake(
() => Promise.try(() => {
if (errorPollTask) {
throw new errors.ServiceUnavailable('Bosh Down...');
}
return {};
}));
getDeploymentVMsStub.withArgs().returns(Promise.resolve(deploymentVms));
getDeploymentStub.withArgs('service-fabrik-mongodb-new').returns(deferred.promise);
getDeploymentStub.withArgs('service-fabrik-mongodb').returns(Promise.resolve({}));
});
function getUserName () {
var username;
username = readlineSync.question(clcQuestion('\n[❓] First administrator account name\n'));
if (username.length === 0) {
return getUserName();
}
return Promise.resolve(username);
}
private getMaxConfiguredReplicaCount(): Promise {
if (this.maximumReplicaCount > 0) {
return Promise.resolve(this.maximumReplicaCount);
} else {
return this.encodeInvokeOnRandomTarget(PNCounterGetConfiguredReplicaCountCodec).then((count: number) => {
this.maximumReplicaCount = count;
return this.maximumReplicaCount;
});
}
}
session() {
if (this.cached_session) {
return Promise.resolve(this.cached_session);
}
return this.client().get(`cache:${this.id}`).then((value) => {
if (value) {
this.cached_session = new Marshal(value).parsed;
}
return this.cached_session;
});
}
}
now (name, ...args) {
return Promise.resolve(
commandFns[name].apply(cy, args)
)
},
function getAllUsedIps(ipList, offset, modelName, searchCriteria) {
if (offset < 0) {
return Promise.resolve([]);
}
const paginateOpts = {
records: config.mongodb.record_max_fetch_count,
offset: offset
};
return Repository.search(modelName, searchCriteria, paginateOpts)
.then((result) => {
ipList.push.apply(ipList, _.map(result.list, (reservedIp) => _.pick(reservedIp, 'ip', 'subnet_range')));
return getAllUsedIps(ipList, result.nextOffset, modelName, searchCriteria);
});
}
const result = [];
function * prepareSource (ref, context, heroku) {
const [filePath, source] = yield [
git.createArchive(ref),
api.createSource(heroku)
]
yield uploadArchive(source.source_blob.put_url, filePath)
return Promise.resolve(source)
}