Skip to content

Commit

Permalink
fix(isolator): remove breaking change in getCapsulesRootDir
Browse files Browse the repository at this point in the history
  • Loading branch information
ocombe committed Jun 21, 2023
1 parent 3a35200 commit aaedff4
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions scopes/component/isolator/isolator.main.runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit aaedff4

Please sign in to comment.