Skip to content

Commit c90dc78

Browse files
committed
feat: rename option
1 parent e375085 commit c90dc78

5 files changed

+18
-18
lines changed

docs/api/inline-fixture-files.defineiffcreatoroptions.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export interface DefineIFFCreatorOptions
1616

1717
| Property | Modifiers | Type | Description |
1818
| --- | --- | --- | --- |
19-
| [useUnixPathSeparator?](./inline-fixture-files.defineiffcreatoroptions.useunixpathseparator.md) | | boolean \| undefined | _(Optional)_ Use unix-style path separator (<code>/</code>) for paths on windows. |
19+
| [unixStylePath?](./inline-fixture-files.defineiffcreatoroptions.unixStylePath.md) | | boolean \| undefined | _(Optional)_ Use unix-style path separator (<code>/</code>) for paths on windows. |
2020

2121
## Methods
2222

Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
22

3-
[Home](./index.md) &gt; [@mizdra/inline-fixture-files](./inline-fixture-files.md) &gt; [DefineIFFCreatorOptions](./inline-fixture-files.defineiffcreatoroptions.md) &gt; [useUnixPathSeparator](./inline-fixture-files.defineiffcreatoroptions.useunixpathseparator.md)
3+
[Home](./index.md) &gt; [@mizdra/inline-fixture-files](./inline-fixture-files.md) &gt; [DefineIFFCreatorOptions](./inline-fixture-files.defineiffcreatoroptions.md) &gt; [unixStylePath](./inline-fixture-files.defineiffcreatoroptions.unixStylePath.md)
44

5-
## DefineIFFCreatorOptions.useUnixPathSeparator property
5+
## DefineIFFCreatorOptions.unixStylePath property
66

77
Use unix-style path separator (`/`<!-- -->) for paths on windows.
88

99
**Signature:**
1010

1111
```typescript
12-
useUnixPathSeparator?: boolean | undefined;
12+
unixStylePath?: boolean | undefined;
1313
```

src/get-paths.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function getSelfAndUpperPaths(path: string): string[] {
4646
export function getPaths<T extends Directory>(
4747
directory: T,
4848
rootDir: string,
49-
useUnixPathSeparator: boolean,
49+
unixStylePath: boolean,
5050
prefix = '',
5151
): FlattenDirectory<T> {
5252
let paths: Record<string, string> = {};
@@ -61,15 +61,15 @@ export function getPaths<T extends Directory>(
6161
// NOTE: Use `Object.defineProperty(obj, prop, { value })` instead of `obj[prop] = value` to allow `paths['__proto__']`.
6262
// ref: https://2ality.com/2015/09/proto-es6.html#defining-__proto__
6363
Object.defineProperty(paths, joinForPosix(prefix, n), {
64-
value: useUnixPathSeparator ? slash(join(rootDir, prefix, n)) : join(rootDir, prefix, n),
64+
value: unixStylePath ? slash(join(rootDir, prefix, n)) : join(rootDir, prefix, n),
6565
enumerable: true,
6666
writable: true,
6767
configurable: true,
6868
});
6969
}
7070

7171
if (isDirectory(item)) {
72-
const newPaths = getPaths(item, rootDir, useUnixPathSeparator, joinForPosix(prefix, name));
72+
const newPaths = getPaths(item, rootDir, unixStylePath, joinForPosix(prefix, name));
7373
paths = { ...paths, ...newPaths };
7474
}
7575
}
@@ -79,11 +79,11 @@ export function getPaths<T extends Directory>(
7979
export function changeRootDirOfPaths<T extends FlattenDirectory<Directory>>(
8080
paths: T,
8181
newRootDir: string,
82-
useUnixPathSeparator: boolean,
82+
unixStylePath: boolean,
8383
): T {
8484
const newPaths: Record<string, string> = {};
8585
for (const key of Object.keys(paths)) {
86-
newPaths[key] = useUnixPathSeparator ? slash(join(newRootDir, key)) : join(newRootDir, key);
86+
newPaths[key] = unixStylePath ? slash(join(newRootDir, key)) : join(newRootDir, key);
8787
}
8888
return newPaths as unknown as T;
8989
}

src/index.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ describe('CreateIFFResult', () => {
211211
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
212212
iff.paths['b/b.txt'];
213213
});
214-
test.runIf(process.platform === 'win32')('useUnixPathSeparator', async () => {
215-
const createIFF = defineIFFCreator({ generateRootDir: () => fixtureDir, useUnixPathSeparator: true });
214+
test.runIf(process.platform === 'win32')('unixStylePath', async () => {
215+
const createIFF = defineIFFCreator({ generateRootDir: () => fixtureDir, unixStylePath: true });
216216
const iff = await createIFF({
217217
'a.txt': 'a',
218218
'b': {
@@ -234,8 +234,8 @@ describe('CreateIFFResult', () => {
234234
expect(iff.join('nonexistent-file.txt')).toBe(join(fixtureDir, 'nonexistent-file.txt'));
235235
expect(iff.join('')).toBe(fixtureDir);
236236
});
237-
test.runIf(process.platform === 'win32')('useUnixPathSeparator', async () => {
238-
const createIFF = defineIFFCreator({ generateRootDir: () => fixtureDir, useUnixPathSeparator: true });
237+
test.runIf(process.platform === 'win32')('unixStylePath', async () => {
238+
const createIFF = defineIFFCreator({ generateRootDir: () => fixtureDir, unixStylePath: true });
239239
const iff = await createIFF({});
240240
expect(iff.join('a.txt')).toBe(slash(join(fixtureDir, 'a.txt')));
241241
});

src/index.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export interface DefineIFFCreatorOptions {
4141
*/
4242
generateRootDir(): string;
4343
/** Use unix-style path separator (`/`) for paths on windows. */
44-
useUnixPathSeparator?: boolean | undefined;
44+
unixStylePath?: boolean | undefined;
4545
}
4646

4747
/**
@@ -251,17 +251,17 @@ export function defineIFFCreator(defineIFFCreatorOptions: DefineIFFCreatorOption
251251
__INTERNAL__prevIFF?: CreateIFFResult<U>,
252252
): Promise<CreateIFFResult<MergeDirectory<U, T>>> {
253253
const rootDir = options?.overrideRootDir ?? defineIFFCreatorOptions.generateRootDir();
254-
const useUnixPathSeparator = defineIFFCreatorOptions.useUnixPathSeparator ?? false;
254+
const unixStylePath = defineIFFCreatorOptions.unixStylePath ?? false;
255255
const paths = {
256-
...changeRootDirOfPaths(__INTERNAL__prevIFF?.paths ?? ({} as FlattenDirectory<U>), rootDir, useUnixPathSeparator),
257-
...getPaths(directory, rootDir, useUnixPathSeparator),
256+
...changeRootDirOfPaths(__INTERNAL__prevIFF?.paths ?? ({} as FlattenDirectory<U>), rootDir, unixStylePath),
257+
...getPaths(directory, rootDir, unixStylePath),
258258
} as FlattenDirectory<MergeDirectory<U, T>>;
259259

260260
const iff: CreateIFFResult<MergeDirectory<U, T>> = {
261261
rootDir,
262262
paths,
263263
join(...paths) {
264-
return useUnixPathSeparator ? slash(join(rootDir, ...paths)) : join(rootDir, ...paths);
264+
return unixStylePath ? slash(join(rootDir, ...paths)) : join(rootDir, ...paths);
265265
},
266266
async rmRootDir() {
267267
await rm(rootDir, { recursive: true, force: true });

0 commit comments

Comments
 (0)