mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 14:36:25 +00:00
fix: use managerConfig correctly (#4864)
Fixes a bug where the manager config was not being passed through correctly.
This commit is contained in:
parent
3613ba882d
commit
71b25d5deb
6 changed files with 32 additions and 22 deletions
|
@ -11,9 +11,16 @@ async function extractAllDependencies(config) {
|
|||
const extractions = {};
|
||||
let fileCount = 0;
|
||||
for (const manager of getManagerList()) {
|
||||
if (
|
||||
config.enabledManagers.length &&
|
||||
!config.enabledManagers.includes(manager)
|
||||
) {
|
||||
logger.debug(`${manager} is not in enabledManagers list - skipping`);
|
||||
continue; // eslint-disable-line
|
||||
}
|
||||
const managerConfig = getManagerConfig(config, manager);
|
||||
managerConfig.manager = manager;
|
||||
const packageFiles = await getManagerPackageFiles(config, managerConfig);
|
||||
const packageFiles = await getManagerPackageFiles(managerConfig);
|
||||
if (packageFiles && packageFiles.length) {
|
||||
fileCount += packageFiles.length;
|
||||
logger.info(`Found ${manager} package files`);
|
||||
|
|
|
@ -17,30 +17,19 @@ const {
|
|||
getMatchingFiles,
|
||||
} = require('./file-match');
|
||||
|
||||
async function getManagerPackageFiles(config, managerConfig) {
|
||||
const { manager, enabled, includePaths, ignorePaths } = managerConfig;
|
||||
async function getManagerPackageFiles(config) {
|
||||
const { manager, enabled, includePaths, ignorePaths } = config;
|
||||
logger.trace(`getPackageFiles(${manager})`);
|
||||
if (!enabled) {
|
||||
logger.debug(`${manager} is disabled`);
|
||||
return [];
|
||||
}
|
||||
if (
|
||||
config.enabledManagers.length &&
|
||||
!config.enabledManagers.includes(manager)
|
||||
) {
|
||||
logger.debug(`${manager} is not in enabledManagers list`);
|
||||
return [];
|
||||
}
|
||||
let fileList = await platform.getFileList();
|
||||
fileList = getIncludedFiles(fileList, includePaths);
|
||||
fileList = filterIgnoredFiles(fileList, ignorePaths);
|
||||
const matchedFiles = getMatchingFiles(
|
||||
fileList,
|
||||
manager,
|
||||
managerConfig.fileMatch
|
||||
);
|
||||
const matchedFiles = getMatchingFiles(fileList, manager, config.fileMatch);
|
||||
// istanbul ignore else
|
||||
if (matchedFiles.length) {
|
||||
if (matchedFiles && matchedFiles.length) {
|
||||
logger.debug(
|
||||
`Matched ${
|
||||
matchedFiles.length
|
||||
|
|
|
@ -115,3 +115,11 @@ Object {
|
|||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`workers/repository/extract/index extractAllDependencies() skips non-enabled maangers 1`] = `
|
||||
Object {
|
||||
"npm": Array [
|
||||
Object {},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
|
|
@ -16,7 +16,7 @@ Array [
|
|||
"packageJsonType": "app",
|
||||
"packageJsonVersion": undefined,
|
||||
"pnpmShrinkwrap": "pnpm-lock.yaml",
|
||||
"skipInstalls": true,
|
||||
"skipInstalls": undefined,
|
||||
"yarnLock": "yarn.lock",
|
||||
"yarnWorkspacesPackages": undefined,
|
||||
"yarnrc": "{}",
|
||||
|
|
|
@ -18,5 +18,11 @@ describe('workers/repository/extract/index', () => {
|
|||
const res = await extractAllDependencies(config);
|
||||
expect(res).toMatchSnapshot();
|
||||
});
|
||||
it('skips non-enabled maangers', async () => {
|
||||
config.enabledManagers = ['npm'];
|
||||
managerFiles.getManagerPackageFiles.mockReturnValue([{}]);
|
||||
const res = await extractAllDependencies(config);
|
||||
expect(res).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -22,19 +22,19 @@ describe('workers/repository/extract/manager-files', () => {
|
|||
});
|
||||
it('returns empty of manager is disabled', async () => {
|
||||
const managerConfig = { manager: 'travis', enabled: false };
|
||||
const res = await getManagerPackageFiles(config, managerConfig);
|
||||
const res = await getManagerPackageFiles(managerConfig);
|
||||
expect(res).toHaveLength(0);
|
||||
});
|
||||
it('returns empty of manager is not enabled', async () => {
|
||||
config.enabledManagers = ['npm'];
|
||||
const managerConfig = { manager: 'docker', enabled: true };
|
||||
const res = await getManagerPackageFiles(config, managerConfig);
|
||||
const res = await getManagerPackageFiles(managerConfig);
|
||||
expect(res).toHaveLength(0);
|
||||
});
|
||||
it('skips files if null content returned', async () => {
|
||||
const managerConfig = { manager: 'npm', enabled: true };
|
||||
fileMatch.getMatchingFiles.mockReturnValue(['package.json']);
|
||||
const res = await getManagerPackageFiles(config, managerConfig);
|
||||
const res = await getManagerPackageFiles(managerConfig);
|
||||
expect(res).toHaveLength(0);
|
||||
});
|
||||
it('returns files with extractPackageFile', async () => {
|
||||
|
@ -42,7 +42,7 @@ describe('workers/repository/extract/manager-files', () => {
|
|||
fileMatch.getMatchingFiles.mockReturnValue(['Dockerfile']);
|
||||
platform.getFile.mockReturnValue('some content');
|
||||
dockerfile.extractPackageFile = jest.fn(() => ({ some: 'result' }));
|
||||
const res = await getManagerPackageFiles(config, managerConfig);
|
||||
const res = await getManagerPackageFiles(managerConfig);
|
||||
expect(res).toMatchSnapshot();
|
||||
});
|
||||
it('returns files with extractAllPackageFiles', async () => {
|
||||
|
@ -50,7 +50,7 @@ describe('workers/repository/extract/manager-files', () => {
|
|||
fileMatch.getMatchingFiles.mockReturnValue(['package.json']);
|
||||
platform.getFile.mockReturnValue('{}');
|
||||
npm.extractPackageFile = jest.fn(() => ({ some: 'result' }));
|
||||
const res = await getManagerPackageFiles(config, managerConfig);
|
||||
const res = await getManagerPackageFiles(managerConfig);
|
||||
expect(res).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue