Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Absolute ignore paths only work against absolute globs #113

Closed
davidtheclark opened this issue Jul 20, 2018 · 2 comments
Closed

Absolute ignore paths only work against absolute globs #113

davidtheclark opened this issue Jul 20, 2018 · 2 comments
Assignees

Comments

@davidtheclark
Copy link

Environment

Node 8.
fast-glob v2.2.2

Actual behavior

I have format.js in the same directory as this script.

fastGlob('format.js', {
  ignore: [path.join(__dirname, '**')],
  cwd: __dirname
}).then(results => {
  console.log(results); // ['format.js']
});

fastGlob(path.join(__dirname, 'format.js'), {
  ignore: [path.join(__dirname, '**')],
  cwd: __dirname
}).then(results => {
  console.log(results); // []
});

Expected behavior

I expect that absolute ignore paths will work against non-absolute globs. Instead, it seems like I need an absolute glob for an absolute ignore path to work.

I think I can work around this for now by making both globs and ignore paths relative to what I pass in as cwd.

@mrmlnc mrmlnc self-assigned this Aug 14, 2018
@mrmlnc mrmlnc added Type: Bug and removed Type: Bug labels Oct 2, 2018
@mrmlnc
Copy link
Owner

mrmlnc commented Oct 21, 2018

Right now this is the expected behavior because we are using user input as the primary path.

In the first case, you say that you want to take the file from the directory. The cwd parameter points to a directory, but does not participate in the path formation for the found occurrences.

The glob package has the same behavior. However, it works in glob correctly when you use the absolute option.

g.sync('index.d.ts', {
	ignore: [path.join(__dirname, '**')],
	absolute: true, // TRUE -> [] FALSE -> [index.d.ts]
	cwd: __dirname
});

In this case, the bug is that we do not use the option of forming a path when filtering.

@mrmlnc
Copy link
Owner

mrmlnc commented Nov 9, 2018

Will be shipped at #136.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants