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

base option possibly not reflecting correct default value #129

Closed
treshugart opened this issue Nov 12, 2015 · 5 comments
Closed

base option possibly not reflecting correct default value #129

treshugart opened this issue Nov 12, 2015 · 5 comments

Comments

@treshugart
Copy link
Contributor

Forgive me if I'm not understanding something correctly here. In the base option, you say:

Default is where the glob begins if any.

This I think I understand correctly in that if you specify something/** that base will be something and ** will be the glob.

However, you also say:

Default is process.cwd() if there is no glob.

What is considered "not a glob"? Is this something that doesn't contain a pattern? An empty string? A relative path? An absolute path?

If an absolute path classifies as a non-glob argument, then if you do something like:

vinylFs.src(['/file/path1.js', '/file/path2.js']);

Then the base is automatically set as /file instead of whatever the current working directory is. That said, I can kind of see the point of this because if you had two completely separate globs that the base path would be ambiguous. But then why have it default at all? The only way a base path could be unambiguous would be if you passed a string glob instead of an array.

In order to get around this you can force the base option via the second argument but I'm still wondering if this is the correct behaviour.

@phated
Copy link
Member

phated commented Nov 12, 2015

You are specifying absolute paths. All paths are resolved using node's path.resolve method, so if we do path.resolve(process.cwd(), '/file/path1.js') it is going to result in the absolute path of /file/path1.js. To make your paths relative, prefix them with . or don't put the / as is standard unix convention.

@phated phated closed this as completed Nov 12, 2015
@treshugart
Copy link
Contributor Author

I understand the unix convention and node's path resolution semantics but that wasn't my question. My question is: what is considered "not a glob"?

And depending on that answer, why is the base reporting as the dirname for the files? Shouldn't it be process.cwd() like the docs say?

@phated
Copy link
Member

phated commented Nov 12, 2015

Anything that doesn't have glob magic is "not a glob". The base property on vinyl objects is resolved by glob2base at https://github.com/gulpjs/glob-stream/blob/master/index.js#L27 but will be switching to glob-parent in gulpjs/glob-stream#56 which has the same behavior.

@treshugart
Copy link
Contributor Author

Anything that doesn't have glob magic is "not a glob".

So:

Default is process.cwd() if there is no glob.

Means that base should be process.cwd() instead of /file for /file/path.js right?

@phated
Copy link
Member

phated commented Nov 12, 2015

No, it gets resolved

treshugart added a commit to treshugart/vinyl-fs that referenced this issue Nov 12, 2015
phated added a commit that referenced this issue Dec 16, 2015
#129 - Update documentation to more clearly explain what happens for default base option values.
phated pushed a commit that referenced this issue Nov 27, 2017
phated pushed a commit that referenced this issue Nov 27, 2017
phated pushed a commit that referenced this issue Nov 27, 2017
phated pushed a commit that referenced this issue Nov 27, 2017
phated pushed a commit that referenced this issue Nov 27, 2017
phated pushed a commit that referenced this issue Nov 27, 2017
phated pushed a commit that referenced this issue Nov 27, 2017
phated pushed a commit that referenced this issue Nov 28, 2017
phated pushed a commit that referenced this issue Nov 28, 2017
phated pushed a commit that referenced this issue Nov 28, 2017
phated pushed a commit that referenced this issue Nov 28, 2017
phated pushed a commit that referenced this issue Nov 28, 2017
phated pushed a commit that referenced this issue Nov 28, 2017
phated pushed a commit that referenced this issue Nov 28, 2017
phated pushed a commit that referenced this issue Nov 28, 2017
phated pushed a commit that referenced this issue Nov 28, 2017
phated pushed a commit that referenced this issue Nov 28, 2017
phated pushed a commit that referenced this issue Nov 28, 2017
phated pushed a commit that referenced this issue Nov 28, 2017
phated pushed a commit that referenced this issue Nov 28, 2017
phated pushed a commit that referenced this issue Nov 28, 2017
phated pushed a commit that referenced this issue Nov 28, 2017
phated pushed a commit that referenced this issue Nov 28, 2017
phated pushed a commit that referenced this issue Nov 28, 2017
phated pushed a commit that referenced this issue Dec 5, 2017
phated added a commit that referenced this issue Dec 5, 2017
#129 - Update documentation to more clearly explain what happens for default base option values.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants