Skip to content

Commit

Permalink
allow ignore pattern for file location
Browse files Browse the repository at this point in the history
  • Loading branch information
tada5hi committed Aug 11, 2022
1 parent 37c256e commit a48fb3d
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"test": "cross-env NODE_ENV=test jest --config ./test/jest.config.js",
"test:coverage": "cross-env NODE_ENV=test jest --config ./test/jest.config.js --coverage",
"lint": "eslint --ext .js,.vue,.ts ./src",
"lint:fix": "npm run lint -- --fix"
"lint:fix": "npm run lint -- --fix",
"prepublishOnly": "npm run build"
},
"keywords": [
"file",
Expand Down
2 changes: 2 additions & 0 deletions src/locator/async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export async function locateFiles(
absolute: true,
cwd: options.path[j],
nodir: true,
ignore: options.ignore,
});

for (let k = 0; k < files.length; k++) {
Expand Down Expand Up @@ -64,6 +65,7 @@ export async function locateFile(
absolute: true,
cwd: options.path[j],
nodir: true,
ignore: options.ignore,
});

const element = files.shift();
Expand Down
2 changes: 2 additions & 0 deletions src/locator/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export function locateFilesSync(
absolute: true,
cwd: options.path[j],
nodir: true,
ignore: options.ignore,
});

for (let k = 0; k < files.length; k++) {
Expand Down Expand Up @@ -61,6 +62,7 @@ export function locateFileSync(
absolute: true,
cwd: options.path[j],
nodir: true,
ignore: options.ignore,
});

const element = files.shift();
Expand Down
1 change: 1 addition & 0 deletions src/locator/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export type LocatorInfo = {

export type LocatorOptions = {
path: string | string[],
ignore: string | string[]
};
2 changes: 2 additions & 0 deletions src/locator/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export function buildLocatorOptions(options?: Partial<LocatorOptions>) : Locator
options.path.push(process.cwd());
}

options.ignore ??= [];

return options as LocatorOptions;
}

Expand Down

0 comments on commit a48fb3d

Please sign in to comment.