From fbb23873e76d76a822246d94ea03fca659f9c873 Mon Sep 17 00:00:00 2001 From: Olivier Combe Date: Wed, 21 Jun 2023 10:56:15 +0200 Subject: [PATCH] fix(isolator): remove breaking change in `getCapsulesRootDir` --- .../isolator/isolator.main.runtime.ts | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/scopes/component/isolator/isolator.main.runtime.ts b/scopes/component/isolator/isolator.main.runtime.ts index f46829280fb7..17da3c9a1264 100644 --- a/scopes/component/isolator/isolator.main.runtime.ts +++ b/scopes/component/isolator/isolator.main.runtime.ts @@ -689,21 +689,27 @@ export class IsolatorMain { } } - getCapsulesRootDir({ - baseDir, - rootBaseDir, + /** @deprecated use the new function signature with an object parameter instead */ + getCapsulesRootDir(baseDir: string, rootBaseDir?: string, useHash?: boolean): PathOsBasedAbsolute; + getCapsulesRootDir(getCapsuleDirOpts: GetCapsuleDirOpts): PathOsBasedAbsolute; + getCapsulesRootDir( + getCapsuleDirOpts: GetCapsuleDirOpts | string, + rootBaseDir?: string, useHash = true, - useDatedDirs = false, - }: GetCapsuleDirOpts): PathOsBasedAbsolute { - const capsulesRootBaseDir = rootBaseDir || this.getRootDirOfAllCapsules(); - if (useDatedDirs) { + useDatedDirs = false + ): PathOsBasedAbsolute { + if (typeof getCapsuleDirOpts === 'string') { + getCapsuleDirOpts = { baseDir: getCapsuleDirOpts, rootBaseDir, useHash, useDatedDirs }; + } + const capsulesRootBaseDir = getCapsuleDirOpts.rootBaseDir || this.getRootDirOfAllCapsules(); + if (getCapsuleDirOpts.useDatedDirs) { const date = new Date(); const dateDir = `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`; const datedBaseDir = 'dated-capsules'; const hashDir = v4(); return path.join(capsulesRootBaseDir, datedBaseDir, dateDir, hashDir); } - const dir = useHash ? hash(baseDir) : baseDir; + const dir = getCapsuleDirOpts.useHash ? hash(getCapsuleDirOpts.baseDir) : getCapsuleDirOpts.baseDir; return path.join(capsulesRootBaseDir, dir); }