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

Support absolute import paths in less files #107

Merged
merged 4 commits into from
Dec 16, 2019

Conversation

tobiasso85
Copy link
Contributor

@tobiasso85 tobiasso85 commented Dec 11, 2019

Absolute import paths are supported with this change

e.g. file
test/fixtures/libraries/scopes/comments/lib3/comments/themes/bar/library.source.less

@import "/lib3/comments/themes/other/sub/my.less";

will be passed as "/lib3/comments/themes/other/sub/my.less" to the filesystem.

Before it was interpreted as a relative path (without the leading slash ("/").

This is especially useful when the filesystem layer is abstracted such as @ui5/fs.

lib/index.js Outdated
const pathname = path.posix.join(currentFileInfo.currentDirectory, file);
let pathname = path.posix.join(currentFileInfo.currentDirectory, file);
if (path.isAbsolute(file)) {
pathname = path.posix.join(file);
Copy link
Member

Choose a reason for hiding this comment

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

what is this single join good for? isn't this just a normalize?

Copy link
Member

Choose a reason for hiding this comment

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

and the join call in L153 is unnecessary for an absolute file, maybe better move it into an else branch.

Copy link
Member

Choose a reason for hiding this comment

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

shouldn't it be path.posix.isAbsolute?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what is this single join good for? isn't this just a normalize?

good point, yes join with a single argument is a normalize. Addressed with: d0d7bb1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

shouldn't it be path.posix.isAbsolute?

done with 39df2b1

Copy link
Member

Choose a reason for hiding this comment

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

LGTM. But I don't know the code enough for an approval.

@tobiasso85 tobiasso85 changed the title Less relative import paths Support absolute import paths in less files Dec 12, 2019
@tobiasso85 tobiasso85 merged commit 266b06d into master Dec 16, 2019
@tobiasso85 tobiasso85 deleted the less-relative-import-paths-test branch December 16, 2019 09:45
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

Successfully merging this pull request may close these issues.

None yet

3 participants