mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-13 07:26:26 +00:00
d8cb261ecb
Renames currentVersion to currentValue, newVersion to newValue, newVersionMajor to newMajor, and newVersionMinor to newMinor.
40 lines
1 KiB
JavaScript
40 lines
1 KiB
JavaScript
module.exports = {
|
|
extractDependencies,
|
|
};
|
|
|
|
function extractDependencies(content) {
|
|
let deps = [];
|
|
const npmDepends = content.match(/Npm\.depends\({([\s\S]*?)}\);/);
|
|
if (!npmDepends) {
|
|
return null;
|
|
}
|
|
try {
|
|
deps = npmDepends[1]
|
|
.replace(/(\s|\\n|\\t|'|")/g, '')
|
|
.split(',')
|
|
.map(dep => dep.trim())
|
|
.filter(dep => dep.length)
|
|
.map(dep => dep.split(/:(.*)/))
|
|
.map(arr => {
|
|
const [depName, currentValue] = arr;
|
|
// istanbul ignore if
|
|
if (!(depName && currentValue)) {
|
|
logger.warn({ content }, 'Incomplete npm.depends match');
|
|
}
|
|
return {
|
|
depName,
|
|
currentValue,
|
|
purl: `pkg:npm/${depName.replace('@', '%40')}`,
|
|
versionScheme: 'semver',
|
|
};
|
|
})
|
|
.filter(dep => dep.depName && dep.currentValue);
|
|
} catch (err) /* istanbul ignore next */ {
|
|
logger.warn({ content }, 'Failed to parse meteor package.js');
|
|
}
|
|
// istanbul ignore if
|
|
if (!deps.length) {
|
|
return null;
|
|
}
|
|
return { deps };
|
|
}
|