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

doc,fs: keep consistent with fs.link and fs.linkSync #3912

Closed
wants to merge 1 commit into from

Conversation

yorkie
Copy link
Contributor

@yorkie yorkie commented Nov 19, 2015

So firstly, the destination has a little confusion like I got the log:

Error: EEXIST: file already exists, symlink 'dist/node_modules' -> 'node_modules'

And my source call is:

fs.symlinkSync('dist/node_modules', 'node_modules', 'dir');

Because I thought the first argument stands for destination as the original doc is telling, but it actually is source. Plus, I also make link* and symlinkSync be consistent :-)

@targos
Copy link
Member

targos commented Nov 19, 2015

In man ln the arguments are called TARGET and LINK_NAME. Perhaps we should be consistent with that and pick target and linkName or just name instead ?

@targos targos added doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system. labels Nov 19, 2015
@evanlucas
Copy link
Contributor

man ln will be different across platforms though. On OS X, it is source_file and target_file (or target_dir)

@yorkie
Copy link
Contributor Author

yorkie commented Nov 19, 2015

Ah, I didn't know it's consistent with man command. BTW, if as @evanlucas said, this behaviors are different across platforms, shouldn't the cross-platform Node.js unify it?

(I'm using OSX).

@yorkie
Copy link
Contributor Author

yorkie commented Nov 19, 2015

Oh, @targos @evanlucas Why do you reference the command ln, what I have changed on is symlink(2), am I right? After reading at the man symlink, which uses path1 and path2 as below:

A symbolic link path2 is created to path1 (path2 is the name of the file cre-
ated, path1 is the string used in creating the symbolic link). Either name
may be an arbitrary path name; the files need not be on the same file system.

Then now I'm able to understand why the author of this function used destination as the name of 1st one, because the context said there is a pointer to the file described by the 1st one, that we called it source at other function like fs.link.

However, not all Node.js user is such that familiar with Linux like me, then the naming of arguments in fs.link and fs.symlink were really really confused. So I still proposal that keep consistent with fs.link's naming rule, any thoughts?

@evanlucas
Copy link
Contributor

Ahhh good point. I think that this is less confusing than the current documentation.

LGTM

@@ -665,7 +665,7 @@ is `'file'`) and is only available on Windows (ignored on other platforms).
Note that Windows junction points require the destination path to be absolute. When using
`'junction'`, the `destination` argument will automatically be normalized to absolute path.
Copy link
Member

Choose a reason for hiding this comment

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

You also need to update mentions of "destination path" here.

@targos
Copy link
Member

targos commented Nov 19, 2015

Fair enough, I didn't get that the point was to make it consistent with fs.link, sorry !

@yorkie
Copy link
Contributor Author

yorkie commented Nov 19, 2015

Never mind @targos, fixed nits and updated the naming in source files, LGTY too?

@targos
Copy link
Member

targos commented Nov 19, 2015

@yorkie
Copy link
Contributor Author

yorkie commented Nov 19, 2015

BTW, I found a typo of errors in fs.link and created a new PR at #3917 :-)

@jasnell
Copy link
Member

jasnell commented Nov 19, 2015

@yorkie ... awesome. This LGTM but curious what @nodejs/ctc would think about the semver-iness of this change. It seems like a fairly significant mismatch between the docs, the API and the implementation in JS.

Also, minor nit, can you please update the title of the PR to be doc,fs: to reflect that it's a change to both the doc and the fs module?

@jasnell
Copy link
Member

jasnell commented Nov 19, 2015

I'm going to mark this semver-major for now as a precaution.

@jasnell jasnell added the semver-major PRs that contain breaking changes and should be released in the next major version. label Nov 19, 2015
@yorkie yorkie changed the title doc: keep consistent with fs.link and fs.linkSync doc,fs: keep consistent with fs.link and fs.linkSync Nov 19, 2015
@yorkie
Copy link
Contributor Author

yorkie commented Nov 19, 2015

Done :-)

@yorkie
Copy link
Contributor Author

yorkie commented Nov 23, 2015

How is this going? is the CI happy now? This seems to be suspended over 4 days :-)

@trevnorris
Copy link
Contributor

Just to be clear, this change won't break any existing code or will it?

@piscisaureus
Copy link
Contributor

The documentation change is incorrect. I reverted a similar change in in 5843ae8.

@piscisaureus
Copy link
Contributor

Let me clarify a bit, too.

symlinkSync(destination, path) creates a symbolic link at path which points at destination.

If this patch gets landed, it becomes this:

symlinkSync(srcpath, dstpath) creates a symbolic link at dstpath which points at srcpath.
I find that wording very confusing, I (and I think most people) would assume the source to point at the destination, and not the other way round.

If the fs.link() documentation is unclear, I would prefer to see that fixed rather than applied to other documentation sections.

@yorkie
Copy link
Contributor Author

yorkie commented Nov 24, 2015

Thanks @piscisaureus and now I have some explanations more about this question, the following is a description from man link/ln:

Given one or two arguments, ln creates a link to an existing file source_file.

The above manual seems to use source to stand for the existing file, and the below is also from manual:

How a link points to a file is one of the differences between a hard and symbolic link.

So I think the file pointed from the link should be unified by this manual.

creates a symbolic link at dstpath which points at srcpath

@piscisaureus as you said, I correct your words as: creates a symbolic link/pointer to the source_file, and this link/pointer is named by target_file, so I'm proposing that Node.js should use target instead of dest in link, symlink.

@targos
Copy link
Member

targos commented Nov 24, 2015

creates a symbolic link/pointer to the source_file, and this link/pointer is named by target_file

It's not that easy. In the Linux doc, target is used for the path that the symlink points at: http://man7.org/linux/man-pages/man2/symlink.2.html

@piscisaureus
Copy link
Contributor

@piscisaureus as you said, I correct your words as: creates a symbolic link/pointer to the source_file, and this link/pointer is named by target_file, so I'm proposing that Node.js should use target instead of dest in link, symlink.

A symbolic link points to another path. There doesn't actually need to be a file there. I think "target" is an appropriate name for the path that the symbolic link points to.

link() is different in the sense that it doesn't point at another path - it adds a new name for a file that already exists. It has more in common with rename(old_name, new_name) than it has with symlink - the difference being that link adds a name and rename changes the name. So I would suggest the link docs be made consistent with rename rather than symlink.

You can see the linux man pages do the same thing:

versus

@yorkie
Copy link
Contributor Author

yorkie commented Nov 25, 2015

@piscisaureus I do that agree with you 100%, and I now updated my commits to use target instead of destination. Could you take a look again, thank you guys :-)

@piscisaureus
Copy link
Contributor

LGTM. Thanks for your patience @yorkie!

@evanlucas
Copy link
Contributor

LGTM if CI is happy.

CI: https://ci.nodejs.org/job/node-test-pull-request/844/

@evanlucas
Copy link
Contributor

@yorkie CI doesn't seem to be happy with this change.

https://ci.nodejs.org/job/node-test-commit-osx/1298/nodes=osx1010/console

@yorkie
Copy link
Contributor Author

yorkie commented Nov 25, 2015

Sorry, I guess I have something forgot to update, I will check it again, sorry :-)

@jasnell jasnell removed the semver-major PRs that contain breaking changes and should be released in the next major version. label Dec 1, 2015
@targos
Copy link
Member

targos commented Dec 1, 2015

That's right

@jasnell
Copy link
Member

jasnell commented Dec 1, 2015

@Trott +1... label removed

@jasnell
Copy link
Member

jasnell commented Dec 1, 2015

LGTM
(sorry for the delay reviewing @yorkie , just catching up after vacation ;-) )

@targos
Copy link
Member

targos commented Dec 1, 2015

LGTM

@yorkie
Copy link
Contributor Author

yorkie commented Dec 1, 2015

Btw, if semver is right to marjor, when this would get this merged? Does this get documented?

@yorkie
Copy link
Contributor Author

yorkie commented Dec 1, 2015

Thank you guys :-)

@yorkie
Copy link
Contributor Author

yorkie commented Dec 5, 2015

Ping guys

@Trott
Copy link
Member

Trott commented Dec 5, 2015

@yorkie
Copy link
Contributor Author

yorkie commented Dec 6, 2015

@Trott Why create a new CI? because I didn't push any changes to the last CI.

@Trott
Copy link
Member

Trott commented Dec 6, 2015

Whoops, my mistake.

@targos
Copy link
Member

targos commented Dec 6, 2015

@yorkie your last push was 10 days ago, it can be possible that new commits on master make the changes in this PR fail

@Trott
Copy link
Member

Trott commented Dec 6, 2015

FWIW, the latest CI passed except for known-flaky tests on Windows (including one that would be fixed by #4062, hey someone go look at that and give it an LGTM if you're comfy with the change, will ya?).

Trott pushed a commit that referenced this pull request Dec 6, 2015
PR-URL: #3912
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Evan Lucas <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Bert Belder <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
@Trott
Copy link
Member

Trott commented Dec 6, 2015

Landed in 8c35903

(The patch didn't apply cleanly on fs.markdown so check my work carefully on that one to make sure I didn't mess anything up.)

@Trott Trott closed this Dec 6, 2015
@yorkie yorkie deleted the improve/fs-doc branch December 6, 2015 05:51
@yorkie
Copy link
Contributor Author

yorkie commented Dec 6, 2015

@Trott I guess you missed to add @trevnorris to reviewers list at 8c35903

@yorkie
Copy link
Contributor Author

yorkie commented Dec 6, 2015

Never mind, that's my fault, thank you Trott :-)

rvagg pushed a commit that referenced this pull request Dec 8, 2015
PR-URL: #3912
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Evan Lucas <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Bert Belder <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
@rvagg rvagg mentioned this pull request Dec 17, 2015
MylesBorins pushed a commit that referenced this pull request Dec 29, 2015
PR-URL: #3912
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Evan Lucas <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Bert Belder <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jan 19, 2016
PR-URL: #3912
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Evan Lucas <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Bert Belder <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Jan 19, 2016
scovetta pushed a commit to scovetta/node that referenced this pull request Apr 2, 2016
PR-URL: nodejs#3912
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Evan Lucas <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Bert Belder <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants