Coder Social home page Coder Social logo

globby's People

Contributors

aaronccasanova avatar alexander-alvarez avatar antongolub avatar arthurvr avatar bendingbender avatar brandon93s avatar catdad avatar chrisblossom avatar coreyfarrell avatar djmattyg007 avatar doochik avatar fisker avatar fwouts avatar iamnapo avatar jamestalmage avatar jamiekyle-eb avatar jopemachine avatar kevva avatar lkummer avatar marionebl avatar medusalix avatar moeriki avatar mrmlnc avatar nzakas avatar popomore avatar schnittstabil avatar sinchang avatar sindresorhus avatar ultcombo avatar voxpelli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

globby's Issues

No match found when pattern contains parentheses

If the specified pattern contains parentheses, no match is ever found, even when the path exists.

const globby = require('globby');

(async () => {
  const glob = './any(directory)/file.txt';
  const paths = await globby(glob);

  console.log(paths); //always logs an empty array
})();

Tested environments...

macOS 10.13.3
globby 8.0.0
node 7.10.0
npm 5.6.0

Windows 10.0.16299 Pro
globby 8.0.0
node 9.5.0
npm 5.6.0

Option to only return files

Currently, globby or rather glob returns both directories and files. You can turn off returning directories using the nodir: true glob option, but that's not what you want. You'd rather want to expand directories into files. That's what this option should do. So globby.sync('foo') where foo is a directory would be expanded into all the files in that directory that doesn't match any of the ignore patterns. Same with globby.sync('foo/**'). There also needs to be a way to specify an array of extensions. In many cases you wouldn't want the expansion to happen for all files, but, for example, just .js files. It should override the nodir option if specified by the user.

This would be useful and simplify code in AVA, XO, cpy, imagemin-cli, and other tools expecting files. For example: https://github.com/avajs/ava-files/blob/master/index.js#L212-L271

@UltCombo @schnittstabil @jamestalmage @SamVerschueren @novemberborn Thoughts?

Feature request: negative patterns removing parent paths too

If you have a match like ['parent/**','!/parent/level1/level2/test.txt']
currently the parent directories of test.txt will remain in the matching list:

'parent/'
'parent/level1/'
'parent/level1/level2/'

If you want to use f.e. https://github.com/sindresorhus/del to delete these matches test.txt will be removed too. To delete a directory, but preserve some subset, the parent directories of any negative match need to be removed too.
See also sindresorhus/del#3

** doesn't match ..

Windows 10, Node 10

This finds a lot of files with node_modules in their path.

const paths = await globby(['..'], { ignore: ['**/node_modules/**'] });

Same with this:

const paths = await globby(['..', '!**/node_modules/**'] );

This doesn't include such files:

const paths = await globby(['..'], { ignore: ['../**/node_modules/**'] });

Is this behavior expected or is it a bug?

Bump node version.

If you bump the version to at least node >= 4, you can get rid of the pinkie-promise and object-assign dependencies.
I would be happy to submit a PR if you would like.

maybe? Too slow in big projects

I have had issues with big directories and globby.

When globby searches huge directories it takes very long (> 20min) to return results.
In the mentioned comments below I describe the following behavior.

proj
  - path/to/code/src (3 directories, 1 level nesting, 20 files)
  - assets (10 directories, 3 level nesting, 100 files)
  - dirt (100 directories, 10 level nesting, 1000 files)
globby('path/to/code/src/**/*.js')
// let's wait for 20 mintes
.then(files => {

})

I stumbled upon this when using Ava and XO in a big project.

Metions:
xojs/xo#212 (comment)
avajs/ava#1329 (comment)

If more info is needed I will be happy to provide.

Deduplicate identical file patterns

Issuehunt badges

I think this stopped working with cf55e5c.

This

.then(tasks => arrayUnion.apply(null, tasks));
doesn't work as it's an object, not simple patterns, and here

globby/index.js

Lines 113 to 117 in 9bf9983

const newTask = getPattern(task, dirGlob.sync).map(glob => ({
pattern: glob,
opts: task.opts
}));
return tasks.concat(newTask);
I had to remove the logic to fix #54.

We probably have to use deep equality or improve the handling some other way. The readability of the code could also be improved.

// @kevva

kevva earned $40.00 by resolving this issue!

glob misses folders on some architectures

problem

on my centos7 system, globby doesn't pick up files. it does pick up files on my osx box

example

$ node
> g = require('globby')
> g.sync(`/home/cdieringer/src/proj/packages/*`)
[]
>
(To exit, press ^C again or type .exit)
> // ^C
$ ll /home/cdieringer/src/proj/packages/
total 28
drwxrwxr-x.  7 cdieringer cdieringer 4096 Aug  9 13:51 ./
drwxrwxr-x. 10 cdieringer cdieringer 4096 Aug  9 13:52 ../
drwxrwxr-x.  8 cdieringer cdieringer 4096 Aug  9 13:53 api/
drwxrwxr-x.  5 cdieringer cdieringer 4096 Aug  9 13:52 common/
drwxrwxr-x.  7 cdieringer cdieringer 4096 Aug  9 13:52 e2e/
drwxrwxr-x.  8 cdieringer cdieringer 4096 Aug  9 13:53 ui/

as you can see, my user cannot find the files from globby, but can from bash.

bummer!

Feature request: progress callback

Would you accept a pull request for a final progress callback parameter? This function would be called each time a file or directory is checked for a match, whether the match is successful or not.

"Special" pattern doesn't return files that contains c before ignore chars

We have a case there the result doesn't match the expected outcome
It could be a bug in "glob" itself

---test---

test( 'glob - async (ignore pattern) ', async t => {
	// Setup
	// fs.mkdirSync( 'tmp' );
	fs.writeFileSync( 'tmp/my.comp.spec.js', 'content' );
	fs.writeFileSync( 'tmp/a.spec.js', 'content' );
	fs.writeFileSync( 'tmp/c.spec.js', 'content' );

	// console.log( await m( 'tmp/*[!.comp].spec.js' ));
	t.deepEqual(await m( 'tmp/*[!.comp].spec.js' ), [ 'tmp/a.spec.js', 'tmp/c.spec.js']);
});

.gitattributes settings.

I got curious about your uses of this file, on further investigation I found some nice post on SO. Please have a look since I find it more reasonable.

Globby Fails To Delete Specified Files

I am attempting to create some workflow functions with gulp that look something like this:

gulp.task('clean:docs', function () {
  console.log('current directory: ', require('process').cwd());
  console.log('files:', globby.sync(['./docs/**/*']));
  return del(['docs/**/*']);
});

In the base directory of my project I have a docs directory that I am trying to clear before regenerating documentation. The output of the above function is:

current directory: f:\sites\project-name-here
files: []

and the files remain untouched.

Version 8.0.0 needs git executable on install

Since version 8.0.0 this library or one of its dependencies needs the "git" executable on npm install, which breaks several of our CI builds. I downgraded to 7.1.1 for now.

Is it possible to remove this dependency to git?

Node: 8.9.4
NPM: 5.6.0
OS: Windows Server 2016

Negative globs handling is very slow

See this benchmark comparing glob-stream with globby. Although glob-stream has the overhead of creating streams for the matched files (which is not really significant as there is only 1 matched file in my test), glob-stream is still over 2 times faster than globby.

This is because globby seeks the paths that would be matched by the negative globs generating too many unnecessary file system calls, while glob-stream uses minimatch to handle negative globs.

provide a `map` function for faster async behavior

function handleMatch (individualMatch) {
  // return a promise
}

globby.map([...patterns], handleMatch).then(function (arrayOfPromiseResults)) {

});

essentially the equivalent of:

globby.map([...patterns]).then(function (arrayOfMatches) {
  return Promise.all(arrayOfMatches.map(handleMatch));
});

But it provides better async behavior by not requiring you wait for globby to be done before handling a match.

Version 8 doesn't match relative files up the directory

My project structure

/project
    /src
        - index.js (`globby` is used in this code)
    /files
        - foo.json
        - bar.json

Behavior in v7.1.1

const matches = await globby(['../files/foo.json', '../files/bar.json']);
console.log(matches);
// Output: ['../files/foo.json', '../files/bar.json']

Behavior in v8.0.1

const matches = await globby(['../files/foo.json', '../files/bar.json']);
console.log(matches);
// Output: [ ]

I know these aren't exactly globs but sometimes pure file paths get passed in and I need to globby to return them if they exist. Is this intended behavior, to only support files at the same or lower levels of the file structure?

Node version: 8.9.4

Up array-union version

If array-union gets an upped version, it might be worthwhile to up this one as well, since this is part of where I found the issue in array-union.

Improve performance

This issue is dedicated to gathering ideas on how we can improve performance.

Some things that might help is to do filtering in the correct order to ensure minimal work is done, and cache and memoize as much as possible. The most important thing is that we skip ignored directories like node_modules as early as possible. It's the source of a lot of performance problems. The hard drive is the bottleneck, so we should ensure we interact with it as little as possible.

Some more ideas in #44 and mrmlnc/fast-glob#15

This Node.js feature request would also help a lot: nodejs/node#15699

fast-glob new params to discover dot folders

Upgrading from 6 to 8 (fast-glob change) forced me to use the following options to discover folders with dot:

{dot: true, onlyDirectories: true}

My code now looks like:

await globby('.mutode/mutode-*', {dot: true, onlyDirectories: true})

This is to help those who run into the issue.

How to set basic path?

globby([
'User/me/workspace/test-project',
'!node_modules/**'
]).then(res) // result always match the node_modules file.

I want to use an absolute path in patterns like the above code, and how could I know which directory does globby start to match file?

Async-iteration support

Issuehunt badges

It would be great to see results as they are found. By implementing JavaScript async iteration support, we could be able to have results stream in as they are located.

Filing as a feature request here, because this is my favorite glob library. ๐Ÿคฉ Thanks!!!


IssueHunt Summary

futpib futpib has been rewarded.

Backers (Total: $80.00)

Submitted pull Requests


Tips


IssueHunt has been backed by the following sponsors. Become a sponsor

Performance loss in version 8

I noticed a performance loss when updating to version 8.0.1 in globby.sync().
I try to find a file in some defined folders in a tree of 500 documents.
Using the sync method in this example is about 10 times faster with version 7.1.1

Switching to "fast_glob" does not seem to be faster in any case,
or maybe you see potential to optimize the used patterns or options?

Globby 8 ignores negated patterns (['!/path']

It looks like the latest version behaves differently from 7.1.1 for negated patterns.

['src\scss\\*.{scss,sass}', '!src\scss\\_*.{scss,sass}']

works as expected in v7.1.1 but does not work in v8 at the moment.

Expands directories is not working with cwd option

Hi. with different cwd, expands directories is not working.

โ””โ”€โ”€ a/
  โ”œโ”€โ”€ b
  โ””โ”€โ”€ c/
    โ”œโ”€โ”€ d
    โ””โ”€โ”€ e
// in directory 'a'

globby('c') // ['c/d', 'c/e']
globby('c', { cwd: process.cwd() }) // ['c/d', 'c/e']
globby('a', { cwd: path.resolve(process.cwd(), '..') }) //  []
globby('a/**/*', { cwd: path.resolve(process.cwd(), '..') }) // ['a/b', 'a/c/d', 'a/c/e']

thanks

passing in improper pattern values throws instead of rejecting the promise

There is no validation on the patterns. It is assumed that they can be used, and the code throws an error if they can't instead of rejecting the promise and triggering the catch.

Example:

globby([null]).then(...).catch(function(err) {
  // expect error to happen
});

This throws here, where the expectation is that it can read the pattern as a string when it is not a string.

Ignore paths on Windows

Im working with globby 8.0.1
I'm passing this paths [ '.', '!docs', '!package-lock.json', '!public', '!node_modules' ] to globby.

In Unix works fine.

But in windows, the ignored paths doesn't work, and all paths that should be ignored pass through globby.

What am I doing wrong?

Add an events or streaming API

Right now, globby only returns the matched paths after all the globbing work is done. It would be nice to have an evented or streaming API to be notified as soon as a file is matched.

How do I use this?

I don't understand what this is supposed to do. At what point do I install and use this? Obviously, I have to create my git repository first, but in what order do I use globby, before my first commit or after? How does this work exactly, within the work flow? I'm using node/npm, with webpack, and vanilla js, and a few other npm packages. I am not using gulp or grunt at this point.

I was hoping this would take care of the .gitignore problem, giving me a way to easily exclude it from my public github repository.

Thanks! :)

Respect `gitignore` from above

Issuehunt badges

Currently only gitignores from cwd and down are taken into account for gitignore filtering. What about those who are higher in a hierarchy?

Use case: monorepo repositories (like babel for example), where gitignore is placed in root and individual packages do not have their own.

There is a $80.00 open bounty on this issue. Add more on Issuehunt.

How to find a `folder` that are not inside `folder`

The task is to find all node_modules in the project tree, that are not inside other node_modules.

I tried unsuccessfully something like:

  • ('**/node_modules/', {ignore: '**/node_modules/**/node_modules/'})

  • ('**/node_modules/', {ignore: '**/node_modules/**'})

Any advice on this?

every minute running a cron in nodejs and the globby finds files that are not there anymore

hello,
how are you?
i have a function that run every minute. what is weird is that it looks like to me it finds some data, that is already moved to another location. it must be globby doing it as it not getting any other data.
it looks like this:

incomingInvoiceDirIncomingFiles = await globby(`${incomingInvoiceDir.incoming}/*.pdf`)

Is there any kind of cache in globby ? if so, how can i disable it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.