mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 06:56:24 +00:00
refactor: replace config dot notation in npm lookup
This commit is contained in:
parent
409cd4adde
commit
2323820df9
1 changed files with 14 additions and 15 deletions
|
@ -9,28 +9,27 @@ module.exports = {
|
|||
|
||||
async function getPackageUpdates(config) {
|
||||
logger.trace({ config }, `npm.getPackageUpdates()`);
|
||||
if (config.depType === 'engines') {
|
||||
if (config.depName !== 'node') {
|
||||
const { depType, depName, currentVersion } = config;
|
||||
if (depType === 'engines') {
|
||||
if (depName !== 'node') {
|
||||
logger.debug('Skipping non-node engine');
|
||||
return [];
|
||||
}
|
||||
return nodeManager.getPackageUpdates(config);
|
||||
}
|
||||
let results = [];
|
||||
if (config.currentVersion.startsWith('file:')) {
|
||||
if (currentVersion.startsWith('file:')) {
|
||||
logger.debug(
|
||||
{ dependency: config.depName, currentVersion: config.currentVersion },
|
||||
{ dependency: depName, currentVersion },
|
||||
'Skipping file: dependency'
|
||||
);
|
||||
return [];
|
||||
}
|
||||
if (!isValidSemver(config.currentVersion)) {
|
||||
if (!isValidSemver(currentVersion)) {
|
||||
results.push({
|
||||
depName: config.depName,
|
||||
depName,
|
||||
type: 'warning',
|
||||
message: `Dependency uses tag "\`${
|
||||
config.currentVersion
|
||||
}\`" as its version so that will never be changed by Renovate`,
|
||||
message: `Dependency uses tag "\`${currentVersion}\`" as its version so that will never be changed by Renovate`,
|
||||
});
|
||||
logger.debug(results[0].message);
|
||||
return results;
|
||||
|
@ -39,12 +38,12 @@ async function getPackageUpdates(config) {
|
|||
config.npmrc,
|
||||
config.global ? config.global.exposeEnv : false
|
||||
);
|
||||
const npmDep = await npmApi.getDependency(config.depName);
|
||||
const npmDep = await npmApi.getDependency(depName);
|
||||
if (npmDep) {
|
||||
results = await versions.determineUpgrades(npmDep, config);
|
||||
if (results.length > 0) {
|
||||
logger.info(
|
||||
{ dependency: config.depName },
|
||||
{ dependency: depName },
|
||||
`${results.length} result(s): ${results.map(
|
||||
upgrade => upgrade.newVersion
|
||||
)}`
|
||||
|
@ -54,11 +53,11 @@ async function getPackageUpdates(config) {
|
|||
// If dependency lookup fails then warn and return
|
||||
const result = {
|
||||
type: 'warning',
|
||||
message: `Failed to look up dependency ${config.depName}`,
|
||||
message: `Failed to look up dependency ${depName}`,
|
||||
};
|
||||
results = [result];
|
||||
logger.info(
|
||||
{ dependency: config.depName, packageFile: config.packageFile },
|
||||
{ dependency: depName, packageFile: config.packageFile },
|
||||
result.message
|
||||
);
|
||||
}
|
||||
|
@ -67,9 +66,9 @@ async function getPackageUpdates(config) {
|
|||
npmDep && npmDep.repositoryUrl && npmDep.repositoryUrl.length
|
||||
? npmDep.repositoryUrl
|
||||
: null;
|
||||
if (!result.repositoryUrl && config.depName.startsWith('@types/')) {
|
||||
if (!result.repositoryUrl && depName.startsWith('@types/')) {
|
||||
logger.debug('Setting @types url manually');
|
||||
result.repositoryUrl = `https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/${config.depName.replace(
|
||||
result.repositoryUrl = `https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/${depName.replace(
|
||||
'@',
|
||||
''
|
||||
)}`;
|
||||
|
|
Loading…
Reference in a new issue