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

module: test for directories, fixes require with .. #58

Closed
wants to merge 1 commit into from
Closed

module: test for directories, fixes require with .. #58

wants to merge 1 commit into from

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

@@ -169,23 +169,24 @@ Module._findPath = function(request, paths) {
// For each path
for (var i = 0, PL = paths.length; i < PL; i++) {
var basePath = path.resolve(paths[i], request);
var stats = statPath(basePath);
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
Contributor Author

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!

@rvagg rvagg force-pushed the v0.12 branch 4 times, most recently from d7e65ff to 185d11c Compare December 4, 2014 10:21
@@ -0,0 +1 @@
module.exports = require('../..');
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

rlidwka commented Dec 5, 2014

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
Contributor Author

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

@robertkowalski
Copy link
Contributor Author

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
Contributor Author

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 <info@bnoordhuis.nl>
Reviewed-by: Chris Dickinson <christopher.s.dickinson@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
@bnoordhuis
Copy link
Member

Thanks Robert, landed in 36777d2.

@bnoordhuis bnoordhuis closed this Dec 7, 2014
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=​ahaas@chromium.org

    (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 <clemensb@chromium.org>
    Commit-Queue: Clemens Backes <clemensb@chromium.org>
    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 <vsavu@google.com>
    Commit-Queue: Artem Sumaneev <asumaneev@google.com>
    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=​ahaas@chromium.org

    (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 <clemensb@chromium.org>
    Commit-Queue: Clemens Backes <clemensb@chromium.org>
    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 <vsavu@google.com>
    Commit-Queue: Artem Sumaneev <asumaneev@google.com>
    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=​ahaas@chromium.org

    (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 <clemensb@chromium.org>
    Commit-Queue: Clemens Backes <clemensb@chromium.org>
    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 <vsavu@google.com>
    Commit-Queue: Artem Sumaneev <asumaneev@google.com>
    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 <matteo.collina@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
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.

5 participants