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

Always use slash as join separator for glob patterns #18

Merged
merged 1 commit into from Jun 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions index.js
Expand Up @@ -6,7 +6,7 @@ const getExtensions = extensions => extensions.length > 1 ? `{${extensions.join(

const getPath = (filepath, cwd) => {
const pth = filepath[0] === '!' ? filepath.slice(1) : filepath;
return path.isAbsolute(pth) ? pth : path.join(cwd, pth);
return path.isAbsolute(pth) ? pth : path.posix.join(cwd, pth);
Copy link
Contributor Author

@yhatt yhatt Jun 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While debugging sindresorhus/globby#126, I found out using path.posix.join in this line is to excess.

A returned path by getPath() is used only for check whether there is a directory (via path-type). Thus, it must join by OS-specific separator for returning correct path.

};

const addExtensions = (file, extensions) => {
Expand All @@ -27,18 +27,18 @@ const getGlob = (dir, opts) => {
}

if (opts.files && opts.extensions) {
return opts.files.map(x => path.join(dir, addExtensions(x, opts.extensions)));
return opts.files.map(x => path.posix.join(dir, addExtensions(x, opts.extensions)));
}

if (opts.files) {
return opts.files.map(x => path.join(dir, `**/${x}`));
return opts.files.map(x => path.posix.join(dir, `**/${x}`));
}

if (opts.extensions) {
return [path.join(dir, `**/*.${getExtensions(opts.extensions)}`)];
return [path.posix.join(dir, `**/*.${getExtensions(opts.extensions)}`)];
}

return [path.join(dir, '**')];
return [path.posix.join(dir, '**')];
};

module.exports = (input, opts) => {
Expand Down