mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 22:46:27 +00:00
fix(lerna): Return empty lerna packages if 404 for packages/* (#540)
This commit is contained in:
parent
feffa774d8
commit
434def2bf4
3 changed files with 27 additions and 7 deletions
|
@ -30,16 +30,21 @@ async function setNpmrc(config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function checkForLerna(config) {
|
async function checkForLerna(config) {
|
||||||
const lernaJson = await config.api.getFileContent('lerna.json');
|
const lernaJson = await config.api.getFileJson('lerna.json');
|
||||||
if (!lernaJson) {
|
if (!lernaJson) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
config.logger.debug('Found lerna config');
|
config.logger.debug({ lernaJson }, 'Found lerna config');
|
||||||
|
try {
|
||||||
const lernaPackages = await config.api.getSubDirectories('packages');
|
const lernaPackages = await config.api.getSubDirectories('packages');
|
||||||
if (lernaPackages.length === 0) {
|
if (lernaPackages.length === 0) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
return { lernaPackages };
|
return { lernaPackages };
|
||||||
|
} catch (err) {
|
||||||
|
config.logger.warn('lerna getSubDirectories error');
|
||||||
|
return {};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function initApis(inputConfig, token) {
|
async function initApis(inputConfig, token) {
|
||||||
|
|
|
@ -11,6 +11,8 @@ Object {
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`workers/repository/apis checkForLerna(config) swallows lerna 404 1`] = `Object {}`;
|
||||||
|
|
||||||
exports[`workers/repository/apis detectPackageFiles(config) adds package files to object 1`] = `
|
exports[`workers/repository/apis detectPackageFiles(config) adds package files to object 1`] = `
|
||||||
Array [
|
Array [
|
||||||
"package.json",
|
"package.json",
|
||||||
|
|
|
@ -43,10 +43,23 @@ describe('workers/repository/apis', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('checkForLerna(config)', () => {
|
describe('checkForLerna(config)', () => {
|
||||||
|
it('swallows lerna 404', async () => {
|
||||||
|
const config = {
|
||||||
|
api: {
|
||||||
|
getFileJson: jest.fn(() => ({})),
|
||||||
|
getSubDirectories: jest.fn(() => {
|
||||||
|
throw new Error('some-error');
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
logger,
|
||||||
|
};
|
||||||
|
const res = await apis.checkForLerna(config);
|
||||||
|
expect(res).toMatchSnapshot();
|
||||||
|
});
|
||||||
it('ignores zero length lerna', async () => {
|
it('ignores zero length lerna', async () => {
|
||||||
const config = {
|
const config = {
|
||||||
api: {
|
api: {
|
||||||
getFileContent: jest.fn(() => 'some content'),
|
getFileJson: jest.fn(() => ({})),
|
||||||
getSubDirectories: jest.fn(() => []),
|
getSubDirectories: jest.fn(() => []),
|
||||||
},
|
},
|
||||||
logger,
|
logger,
|
||||||
|
@ -57,7 +70,7 @@ describe('workers/repository/apis', () => {
|
||||||
it('returns lerna package names', async () => {
|
it('returns lerna package names', async () => {
|
||||||
const config = {
|
const config = {
|
||||||
api: {
|
api: {
|
||||||
getFileContent: jest.fn(() => 'some content'),
|
getFileJson: jest.fn(() => ({})),
|
||||||
getSubDirectories: jest.fn(() => ['a', 'b']),
|
getSubDirectories: jest.fn(() => ['a', 'b']),
|
||||||
},
|
},
|
||||||
logger,
|
logger,
|
||||||
|
|
Loading…
Reference in a new issue