Skip to content

Commit

Permalink
DRY a little bit (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Jan 12, 2022
1 parent 60b7116 commit de4082b
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions gitignore.js
Expand Up @@ -82,18 +82,12 @@ const getFileSync = (file, cwd) => {
const normalizeOptions = ({
ignore = [],
cwd = slash(process.cwd()),
} = {}) => ({ignore, cwd});
} = {}) => ({ignore: [...DEFAULT_IGNORE, ...ignore], cwd});

export const isGitIgnored = async options => {
options = normalizeOptions(options);

const paths = await fastGlob('**/.gitignore', {
ignore: [
...DEFAULT_IGNORE,
...options.ignore,
],
cwd: options.cwd,
});
const paths = await fastGlob('**/.gitignore', options);

const files = await Promise.all(paths.map(file => getFile(file, options.cwd)));
const ignores = reduceIgnore(files);
Expand All @@ -104,13 +98,7 @@ export const isGitIgnored = async options => {
export const isGitIgnoredSync = options => {
options = normalizeOptions(options);

const paths = fastGlob.sync('**/.gitignore', {
ignore: [
...DEFAULT_IGNORE,
...options.ignore,
],
cwd: options.cwd,
});
const paths = fastGlob.sync('**/.gitignore', options);

const files = paths.map(file => getFileSync(file, options.cwd));
const ignores = reduceIgnore(files);
Expand Down

0 comments on commit de4082b

Please sign in to comment.