From 4bd4a5f818019b5d39fb6a4a527e47ad3af20d31 Mon Sep 17 00:00:00 2001 From: Bart van den Ende <65355342+bartvandenende-wm@users.noreply.github.com> Date: Tue, 7 May 2024 14:26:57 +0200 Subject: [PATCH] fix: resolve the stagingDir option relative to the bsconfig.json file (#1148) * fix: resolve the stagingDir option relative to the bsconfig.json file * chore: add unit test * Fix windows paths --------- Co-authored-by: Bart van den Ende Co-authored-by: Bronley Plumb --- src/util.spec.ts | 20 ++++++++++++++++++++ src/util.ts | 3 +++ 2 files changed, 23 insertions(+) diff --git a/src/util.spec.ts b/src/util.spec.ts index 8fe14fae6..0d9a59d61 100644 --- a/src/util.spec.ts +++ b/src/util.spec.ts @@ -123,6 +123,26 @@ describe('util', () => { ].map(p => util.pathSepNormalize(p, '/'))); }); + it('resolves path relatively to config file', () => { + const mockConfig: BsConfig = { + outFile: 'out/app.zip', + rootDir: 'rootDir', + cwd: 'cwd', + stagingDir: 'stagingDir' + }; + fsExtra.outputFileSync(s`${rootDir}/child.json`, JSON.stringify(mockConfig)); + let config = util.loadConfigFile(s`${rootDir}/child.json`); + expect(config).to.deep.equal({ + '_ancestors': [ + s`${rootDir}/child.json` + ], + 'cwd': s`${rootDir}/cwd`, + 'outFile': s`${rootDir}/out/app.zip`, + 'rootDir': s`${rootDir}/rootDir`, + 'stagingDir': s`${rootDir}/stagingDir` + }); + }); + it('removes duplicate plugins and undefined values', () => { const config: BsConfig = { plugins: [ diff --git a/src/util.ts b/src/util.ts index 37e297540..e88ba77cc 100644 --- a/src/util.ts +++ b/src/util.ts @@ -234,6 +234,9 @@ export class Util { if (result.cwd) { result.cwd = path.resolve(projectFileCwd, result.cwd); } + if (result.stagingDir) { + result.stagingDir = path.resolve(projectFileCwd, result.stagingDir); + } return result; } }