Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(config): massage package.json>renovate string #12150

Merged
merged 3 commits into from Oct 13, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions lib/workers/repository/init/merge.spec.ts
Expand Up @@ -58,6 +58,25 @@ describe('workers/repository/init/merge', () => {
expect(await detectRepoFileConfig()).toMatchSnapshot();
expect(await detectRepoFileConfig()).toMatchSnapshot();
});
it('massages package.json renovate string', async () => {
git.getFileList.mockResolvedValue(['package.json']);
const pJson = JSON.stringify({
name: 'something',
renovate: 'github>renovatebot/renovate',
});
fs.readLocalFile.mockResolvedValue(pJson);
platform.getJsonFile.mockResolvedValueOnce(pJson);
expect(await detectRepoFileConfig()).toMatchInlineSnapshot(`
Object {
"configFileName": "package.json",
"configFileParsed": Object {
"extends": Array [
"github>renovatebot/renovate",
],
},
}
`);
});
it('returns error if cannot parse', async () => {
git.getFileList.mockResolvedValue(['package.json', 'renovate.json']);
fs.readLocalFile.mockResolvedValue('cannot parse');
Expand Down
4 changes: 4 additions & 0 deletions lib/workers/repository/init/merge.ts
Expand Up @@ -68,6 +68,10 @@ export async function detectRepoFileConfig(): Promise<RepoFileConfig> {
configFileParsed = JSON.parse(
await readLocalFile('package.json', 'utf8')
).renovate;
if (is.string(configFileParsed)) {
logger.debug('Massaging string renovate config to extends array');
configFileParsed = { extends: [configFileParsed] };
}
logger.debug({ config: configFileParsed }, 'package.json>renovate config');
} else {
let rawFileContents = await readLocalFile(configFileName, 'utf8');
Expand Down