From 029267e7772344935bebc7aaeefdbeb02ab1cb53 Mon Sep 17 00:00:00 2001 From: samchungy Date: Tue, 15 Aug 2023 16:00:06 +1000 Subject: [PATCH] resolve path for config --- src/cli/configure/patchRenovateConfig.test.ts | 21 +++++++++++++++++++ src/cli/configure/patchRenovateConfig.ts | 3 ++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/cli/configure/patchRenovateConfig.test.ts b/src/cli/configure/patchRenovateConfig.test.ts index c7d474471..c707d608a 100644 --- a/src/cli/configure/patchRenovateConfig.test.ts +++ b/src/cli/configure/patchRenovateConfig.test.ts @@ -62,6 +62,27 @@ it('patches a JSON config for a SEEK-Jobs project', async () => { `); }); +it('patches a JSON config for a new SEEK-Jobs project', async () => { + getOwnerAndRepo.mockResolvedValue({ owner: 'SEEK-Jobs', repo: 'VersionNet' }); + + vol.fromJSON({ 'foo/.git': null, 'foo/renovate.json': JSON }); + + await expect(tryPatchRenovateConfig('foo')).resolves.toBeUndefined(); + + expect(volToJson()).toMatchInlineSnapshot(` + { + "foo/.git": null, + "foo/renovate.json": "{ + "extends": [ + "local>seek-jobs/renovate-config", + "github>seek-oss/rynovate:third-party-major" + ] + } + ", + } + `); +}); + it('patches a JSON5 config for a seekasia project', async () => { getOwnerAndRepo.mockResolvedValue({ owner: 'sEEkAsIa', diff --git a/src/cli/configure/patchRenovateConfig.ts b/src/cli/configure/patchRenovateConfig.ts index ce9b21701..69f7f2a1e 100644 --- a/src/cli/configure/patchRenovateConfig.ts +++ b/src/cli/configure/patchRenovateConfig.ts @@ -1,5 +1,6 @@ /* eslint-disable new-cap */ +import path from 'path'; import { inspect } from 'util'; import fs from 'fs-extra'; @@ -131,7 +132,7 @@ const patchRenovateConfig = async (dir: string) => { const patchFile = patchByFiletype[filetype]; await patchFile({ - filepath: config.filepath, + filepath: path.resolve(dir, config.filepath), input: config.input, presetToAdd, });