From 2fd3622cd4eddee9176961366933a69e59c1f96f Mon Sep 17 00:00:00 2001 From: Hiroki Osame Date: Tue, 7 May 2024 19:39:42 +0900 Subject: [PATCH] feat: getPath to accept multiple subpaths --- README.md | 4 ++-- src/fs-fixture.ts | 4 ++-- src/index.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 577f89a..f47ecec 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ type Api = { filePath: string // Get path from the root of the fixture - getPath: (subpath: string) => string + getPath: (...subpaths: string[]) => string // Create a symlink symlink: (target: string) => Symlink @@ -136,7 +136,7 @@ class FsFixture { /** Get the full path to a subpath in the fixture directory. */ - getPath(subpath: string): string + getPath(...subpaths: string[]): string /** Check if the fixture exists. Pass in a subpath to check if it exists. diff --git a/src/fs-fixture.ts b/src/fs-fixture.ts index 58cae15..c97630f 100644 --- a/src/fs-fixture.ts +++ b/src/fs-fixture.ts @@ -26,8 +26,8 @@ class FsFixture { /** Get the full path to a subpath in the fixture directory. */ - getPath(subpath: string) { - return path.join(this.path, subpath); + getPath(...subpaths: string[]) { + return path.join(this.path, ...subpaths); } /** diff --git a/src/index.ts b/src/index.ts index ee8bb43..ce2a09b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -21,7 +21,7 @@ class Symlink { type ApiBase = { fixturePath: string; - getPath(subpath: string): string; + getPath(...subpaths: string[]): string; symlink(targetPath: string): Symlink; }; @@ -107,7 +107,7 @@ export const createFixture = async ( // create from json const api: ApiBase = { fixturePath, - getPath: subpath => path.join(fixturePath, subpath), + getPath: (...subpaths) => path.join(fixturePath, ...subpaths), symlink: targetPath => new Symlink(targetPath), }; await Promise.all(