-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Conversation
@@ -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); |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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!
d7e65ff
to
185d11c
Compare
@@ -0,0 +1 @@ | |||
module.exports = require('../..'); |
There was a problem hiding this comment.
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.
Left two comments but apart from that LGTM. Would be good to get more eyeballs. |
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 |
Require subsystem is locked in node.js. Are we changing it here or not? If we are, I want to ask |
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.
thanks for the feedback. I added the additional test and changed the directory of the fixture. |
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 |
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. |
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) |
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>
Thanks Robert, landed in 36777d2. |
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
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
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>
Given my home-directory is
/Users/rocko
- and I have a file namednpm.json
in it and also a repository with namenpm
, which is afolder for the node-module.
When try to require the
/Users/rocko/npm/index.js
two direcotrylevels 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