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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions doc/api/fs.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -656,16 +656,22 @@ information.

Synchronous stat(2). Returns an instance of `fs.Stats`.

## fs.symlink(destination, path[, type], callback)
## fs.symlink(target, path[, type], callback)

Asynchronous symlink(2). No arguments other than a possible exception are given
to the completion callback.
The `type` argument can be set to `'dir'`, `'file'`, or `'junction'` (default
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.
`'junction'`, the `target` argument will automatically be normalized to absolute path.

## fs.symlinkSync(destination, path[, type])
Here is an example below:

fs.symlink('./foo', './new-port');

It would create a symlic link named with "new-port" that points to "foo".

## fs.symlinkSync(target, path[, type])

Synchronous symlink(2). Returns `undefined`.

Expand Down
12 changes: 6 additions & 6 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -920,29 +920,29 @@ function preprocessSymlinkDestination(path, type, linkPath) {
}
}

fs.symlink = function(destination, path, type_, callback_) {
fs.symlink = function(target, path, type_, callback_) {
var type = (typeof type_ === 'string' ? type_ : null);
var callback = makeCallback(arguments[arguments.length - 1]);

if (!nullCheck(destination, callback)) return;
if (!nullCheck(target, callback)) return;
if (!nullCheck(path, callback)) return;

var req = new FSReqWrap();
req.oncomplete = callback;

binding.symlink(preprocessSymlinkDestination(destination, type, path),
binding.symlink(preprocessSymlinkDestination(target, type, path),
pathModule._makeLong(path),
type,
req);
};

fs.symlinkSync = function(destination, path, type) {
fs.symlinkSync = function(target, path, type) {
type = (typeof type === 'string' ? type : null);

nullCheck(destination);
nullCheck(target);
nullCheck(path);

return binding.symlink(preprocessSymlinkDestination(destination, type, path),
return binding.symlink(preprocessSymlinkDestination(target, type, path),
pathModule._makeLong(path),
type);
};
Expand Down
10 changes: 5 additions & 5 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -580,15 +580,15 @@ static void Symlink(const FunctionCallbackInfo<Value>& args) {

int len = args.Length();
if (len < 1)
return TYPE_ERROR("dest path required");
return TYPE_ERROR("target path required");
if (len < 2)
return TYPE_ERROR("src path required");
if (!args[0]->IsString())
return TYPE_ERROR("dest path must be a string");
return TYPE_ERROR("target path must be a string");
if (!args[1]->IsString())
return TYPE_ERROR("src path must be a string");

node::Utf8Value dest(env->isolate(), args[0]);
node::Utf8Value target(env->isolate(), args[0]);
node::Utf8Value path(env->isolate(), args[1]);
int flags = 0;

Expand All @@ -604,9 +604,9 @@ static void Symlink(const FunctionCallbackInfo<Value>& args) {
}

if (args[3]->IsObject()) {
ASYNC_DEST_CALL(symlink, args[3], *path, *dest, *path, flags)
ASYNC_DEST_CALL(symlink, args[3], *path, *target, *path, flags)
} else {
SYNC_DEST_CALL(symlink, *dest, *path, *dest, *path, flags)
SYNC_DEST_CALL(symlink, *target, *path, *target, *path, flags)
}
}

Expand Down