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

fix: inconsistent filepath separators #3632

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/EleventyFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,14 +329,14 @@ class EleventyFiles {
return ret;
}

_globSearch() {
async _globSearch() {
let globs = this.getFileGlobs();

// returns a promise
debug("Searching for: %o", globs);
return this.fileSystemSearch.search("templates", globs, {
return (await this.fileSystemSearch.search("templates", globs, {
ignore: this.uniqueIgnores,
});
})).map(i => i.replace(/\\/g, '/'));
Copy link
Contributor

Choose a reason for hiding this comment

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

Using path.sep would work here, too?

Instead of an IIFE for the promise I think it's okay to add another temporary variable.

Suggested change
})).map(i => i.replace(/\\/g, '/'));
const results = await this.fileSystemSearch.search("templates", globs, {
ignore: this.uniqueIgnores,
});
return results.map(i => i.replace(new RegExp(path.sep, 'g'), '/'));

Untested, as I'm on Debian Linux.

Copy link
Author

Choose a reason for hiding this comment

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

I'll add the temporary variable for clarity, but path.sep would not work here without being escaped. I don't think there'd be any benefit in using it either: replacing linux path separators would not do anything.

}

getPathsWithVirtualTemplates(paths) {
Expand Down