Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
findBySlug: function(name, items) {
if (name != null) {
const item = items.findBy('Name', name);
if (item) {
return this.settings.persist({ dc: get(item, 'Name') }).then(function() {
// TODO: create a model
return { Name: get(item, 'Name') };
});
}
}
const e = new Error();
e.status = '404';
e.detail = 'Page not found';
return Promise.reject({ errors: [e] });
},
getActive: function(name, items) {
transition.router,
transition.sequence,
'Resolved all models on destination route; finalizing transition.'
);
let router = transition.router,
handlerInfos = newState.handlerInfos;
// Run all the necessary enter/setup/exit hooks
setupContexts(router, newState, transition);
// Check if a redirect occurred in enter/setup
if (transition.isAborted) {
// TODO: cleaner way? distinguish b/w targetHandlerInfos?
router.state!.handlerInfos = router.currentHandlerInfos!;
return Promise.reject(logAbort(transition));
}
updateURL(transition, newState, (transition.intent! as URLTransitionIntent).url);
transition.isActive = false;
router.activeTransition = undefined;
trigger(router, router.currentHandlerInfos!, true, 'didTransition');
if (router.didTransition) {
router.didTransition(router.currentHandlerInfos!);
}
log(router, transition.sequence, 'TRANSITION COMPLETE.');
// Resolve with the final handler.
function checkForAbort() {
if (transition.isAborted) {
return Promise.reject(undefined, promiseLabel("Transition aborted - reject"));
}
}
}
}).catch(error => {
this.handleTokenRefreshFail(error.status);
return Promise.reject(error);
});
},
function ajaxSuccess(adapter, payload, requestData, responseData) {
let response;
try {
response = adapter.handleResponse(responseData.status, responseData.headers, payload, requestData);
} catch (error) {
return Promise.reject(error);
}
if (response && response.isAdapterError) {
return Promise.reject(response);
} else {
return response;
}
}
run() {
let packagePath = path.join(this.root, 'package.json');
let packageJSON = getPackage(packagePath);
let homepage = packageJSON.homepage;
if (homepage === undefined || homepage && homepage[0] === '/') {
return Promise.reject(this.warnMsg());
} else {
return Promise.resolve();
}
}
});
module.exports = function resolvePlatform(project, platform) {
if (platform && !validPlatforms.includes(platform)) {
return Promise.reject(`'${platform}' is not a valid platform`);
}
return getPlatforms(project).then((installedPlatforms) => {
if (platform) {
if (!installedPlatforms.includes(platform)) {
let message = `'${platform}' is not an installed platform`;
return Promise.reject(message);
}
return platform;
}
switch (installedPlatforms.length) {
case 0:
return Promise.reject('no platforms installed');
case 1:
function requestPermission() {
if (havePermission === true) {
return Promise.resolve();
} else if (havePermission === false) {
return Promise.reject();
} else {
return new Promise(function (resolve, reject) {
Notification.requestPermission(function (status) {
if (status === "granted") {
resolve();
} else {
reject();
}
});
});
}
}
let platformPath = path.join(
cordovaPath,
'plugins/' + validator.platform + '.json'
);
try {
let platformJSON = require(platformPath);
let plugins = Object.keys(platformJSON.installed_plugins);
if (plugins.indexOf(validator.desiredKeyName) < 0) {
return Promise.reject(validator.makeError(NOT_IN_PLATFORMJSON));
}
return Promise.resolve();
} catch (e) {
return Promise.reject(validator.makeError(NOT_IN_PLATFORMJSON));
}
};