Skip to content

Conversation

@robertkowalski
Copy link
Contributor

Given my home-directory is /Users/rocko - and I have a file named
npm.json in it and also a repository with name npm, which is a
folder for the node-module.

When try to require the /Users/rocko/npm/index.js two direcotry
levels down in the npm folder (e.g. /Users/rocko/npm/test/tap)
with require("../../") node will load /Users/rocko/npm/index.json.

When I use require("../..") node will load /Users/rocko/npm.json
which is fixed by this commit.

Original PR: nodejs/node-v0.x-archive#7094

lib/module.js Outdated
Copy link
Member

Choose a reason for hiding this comment

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

wondering if I'm missing something, why is this done up here and not closer to where it's used, potentially skipping when trailingSlash==true?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

good point! no real reason for that, will fix that!

@rvaggrvaggforce-pushed the v0.12 branch 4 times, most recently from d7e65ff to 185d11cCompareDecember 4, 2014 10:21
Copy link
Member

Choose a reason for hiding this comment

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

It would be good to have a second test that checks that ../../ has the same behavior.

Suggestion: change the file path to a more neutral one, e.g. test/fixtures/json-with-directory-name-module/module-stub/one/two/three.js. The tap/ directory suggests that tap is somehow involved when it's not.

@bnoordhuis
Copy link
Member

Left two comments but apart from that LGTM. Would be good to get more eyeballs.

@rvagg
Copy link
Member

rvagg commented Dec 4, 2014

lgtm, having reviewed the original discussion @ joyent/node I'm a big +1 on consistency and think holding off for some mythical future total rework of the module loader system is a bad idea, let's just land this and think about the future when the future happens

@rlidwka
Copy link
Contributor

Require subsystem is locked in node.js. Are we changing it here or not?

If we are, I want to ask require('.') to be handled the same as require('./'), because the current behavior of require('.') is useless.

Given my home-directory is `/Users/rocko` - and I have a file named `npm.json` in it and also a repository with name `npm`, which is a folder for the node-module. When try to require the `/Users/rocko/npm/index.js` two direcotry levels down in the npm folder (e.g. `/Users/rocko/npm/test/tap`) with require("../../") node will load `/Users/rocko/npm/index.json`. When I use require("../..") node will load `/Users/rocko/npm.json` which is fixed by this commit.
@robertkowalski
Copy link
ContributorAuthor

thanks for the feedback. I added the additional test and changed the directory of the fixture.

@robertkowalski
Copy link
ContributorAuthor

some background info: my last status from joyent was that they want to merge it in an unstable version - they also were quite afraid that it could slow down application startup so i had to create all of these benchmarks in the original pr

@chrisdickinson
Copy link
Contributor

Oh wow, that's weird behavior -- good catch & thanks for fixing it. I'm +1 on changing this behavior, it seems very much like a bug given the docs.

@robertkowalski
Copy link
ContributorAuthor

yes, it is a bug, as you can't reach a directory next to a{js,json}-file which has the same name - with the patch you are able to reach both the file and the directory (by adding the fileending to the require-argument to take the file - or leaving it off to take the directory)

bnoordhuis pushed a commit that referenced this pull request Dec 7, 2014
Given my home-directory is `/Users/rocko` - and I have a file named `npm.json` in it and also a repository with name `npm`, which is a folder for the node-module. When try to require the `/Users/rocko/npm/index.js` two direcotry levels down in the npm folder (e.g. `/Users/rocko/npm/test/tap`) with require("../../") node will load `/Users/rocko/npm/index.json`. When I use require("../..") node will load `/Users/rocko/npm.json` which is fixed by this commit. PR-URL: #58 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-by: Chris Dickinson <[email protected]> Reviewed-By: Rod Vagg <[email protected]>
@bnoordhuis
Copy link
Member

Thanks Robert, landed in 36777d2.

@rvaggrvagg mentioned this pull request Jan 3, 2015
targos added a commit to targos/node that referenced this pull request Apr 17, 2021
Original commit message: Merged: [liftoff][arm] Release temp registers after use The{ParallelRegisterMove} at the end of{AtomicLoad} might need a temporary scratch register for spilling values to the stack. Make sure that one is available by giving up the scratch register used for the address of the atomic access. TBR=​[email protected] (cherry picked from commit 63166010061d2af4fef6a713d448ebf074a9d2cb) (cherry picked from commit 953f7a9dcb1425616e3be67fdfe6ef8d820f0daa) Bug: chromium:1153442 Change-Id: Ie312b37857e226058581b300b5adb1f14476c155 No-Try: true No-Presubmit: true No-Tree-Checks: true Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2584959 Reviewed-by: Clemens Backes <[email protected]> Commit-Queue: Clemens Backes <[email protected]> Cr-Original-Commit-Position: refs/branch-heads/8.7@{nodejs#60} Cr-Original-Branched-From: 0d81cd72688512abcbe1601015baee390c484a6a-refs/heads/8.7.220@{#1} Cr-Original-Branched-From: 942c2ef85caef00fcf02517d049f05e9a3d4b440-refs/heads/master@{#70196} Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2656263 Reviewed-by: Victor-Gabriel Savu <[email protected]> Commit-Queue: Artem Sumaneev <[email protected]> Cr-Commit-Position: refs/branch-heads/8.6@{nodejs#58} Cr-Branched-From: a64aed2333abf49e494d2a5ce24bbd14fff19f60-refs/heads/8.6.395@{#1} Cr-Branched-From: a626bc036236c9bf92ac7b87dc40c9e538b087e3-refs/heads/master@{#69472} Refs: v8/v8@5c6c99a
targos added a commit to targos/node that referenced this pull request Apr 27, 2021
Original commit message: Merged: [liftoff][arm] Release temp registers after use The{ParallelRegisterMove} at the end of{AtomicLoad} might need a temporary scratch register for spilling values to the stack. Make sure that one is available by giving up the scratch register used for the address of the atomic access. TBR=​[email protected] (cherry picked from commit 63166010061d2af4fef6a713d448ebf074a9d2cb) (cherry picked from commit 953f7a9dcb1425616e3be67fdfe6ef8d820f0daa) Bug: chromium:1153442 Change-Id: Ie312b37857e226058581b300b5adb1f14476c155 No-Try: true No-Presubmit: true No-Tree-Checks: true Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2584959 Reviewed-by: Clemens Backes <[email protected]> Commit-Queue: Clemens Backes <[email protected]> Cr-Original-Commit-Position: refs/branch-heads/8.7@{nodejs#60} Cr-Original-Branched-From: 0d81cd72688512abcbe1601015baee390c484a6a-refs/heads/8.7.220@{#1} Cr-Original-Branched-From: 942c2ef85caef00fcf02517d049f05e9a3d4b440-refs/heads/master@{#70196} Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2656263 Reviewed-by: Victor-Gabriel Savu <[email protected]> Commit-Queue: Artem Sumaneev <[email protected]> Cr-Commit-Position: refs/branch-heads/8.6@{nodejs#58} Cr-Branched-From: a64aed2333abf49e494d2a5ce24bbd14fff19f60-refs/heads/8.6.395@{#1} Cr-Branched-From: a626bc036236c9bf92ac7b87dc40c9e538b087e3-refs/heads/master@{#69472} Refs: v8/v8@5c6c99a
targos added a commit that referenced this pull request Apr 30, 2021
Original commit message: Merged: [liftoff][arm] Release temp registers after use The{ParallelRegisterMove} at the end of{AtomicLoad} might need a temporary scratch register for spilling values to the stack. Make sure that one is available by giving up the scratch register used for the address of the atomic access. TBR=​[email protected] (cherry picked from commit 63166010061d2af4fef6a713d448ebf074a9d2cb) (cherry picked from commit 953f7a9dcb1425616e3be67fdfe6ef8d820f0daa) Bug: chromium:1153442 Change-Id: Ie312b37857e226058581b300b5adb1f14476c155 No-Try: true No-Presubmit: true No-Tree-Checks: true Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2584959 Reviewed-by: Clemens Backes <[email protected]> Commit-Queue: Clemens Backes <[email protected]> Cr-Original-Commit-Position: refs/branch-heads/8.7@{#60} Cr-Original-Branched-From: 0d81cd72688512abcbe1601015baee390c484a6a-refs/heads/8.7.220@{#1} Cr-Original-Branched-From: 942c2ef85caef00fcf02517d049f05e9a3d4b440-refs/heads/master@{#70196} Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2656263 Reviewed-by: Victor-Gabriel Savu <[email protected]> Commit-Queue: Artem Sumaneev <[email protected]> Cr-Commit-Position: refs/branch-heads/8.6@{#58} Cr-Branched-From: a64aed2333abf49e494d2a5ce24bbd14fff19f60-refs/heads/8.6.395@{#1} Cr-Branched-From: a626bc036236c9bf92ac7b87dc40c9e538b087e3-refs/heads/master@{#69472} Refs: v8/v8@5c6c99a PR-URL: #38275 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: Shelley Vohr <[email protected]>
Sign up for freeto 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.

5 participants

@robertkowalski@bnoordhuis@rvagg@rlidwka@chrisdickinson