Skip to content

Commit

Permalink
feat: getPath to accept multiple subpaths
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber committed May 7, 2024
1 parent eeea335 commit 2fd3622
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/fs-fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Symlink {

type ApiBase = {
fixturePath: string;
getPath(subpath: string): string;
getPath(...subpaths: string[]): string;
symlink(targetPath: string): Symlink;
};

Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 2fd3622

Please sign in to comment.