Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit 9f473d4

Browse files
committed
meta: merge node/master into node-chakracore/master
Merge f002c3d as of 2017-11-09 This commit was automatically generated. For any problems, please contact jackhorton Reviewed-By: Jack Horton <jahorto@microsoft.com>
2 parents b6b3ed8 + f002c3d commit 9f473d4

File tree

9 files changed

+138
-98
lines changed

9 files changed

+138
-98
lines changed

common.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
# Reset this number to 0 on major V8 upgrades.
3131
# Increment by one for each non-official patch applied to deps/v8.
32-
'v8_embedder_string': '-node.8',
32+
'v8_embedder_string': '-node.9',
3333

3434
# Enable disassembler for `--print-code` v8 options
3535
'v8_enable_disassembler': 1,

deps/v8/src/inspector/inspector.gypi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
'inspector_all_sources': [
3232
'<@(inspector_generated_sources)',
3333
'<(inspector_generated_injected_script)',
34-
'../../include/v8-inspector.h',
35-
'../../include/v8-inspector-protocol.h',
34+
'../include/v8-inspector.h',
35+
'../include/v8-inspector-protocol.h',
3636
'inspector/injected-script.cc',
3737
'inspector/injected-script.h',
3838
'inspector/inspected-context.cc',

lib/fs.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,6 +1722,14 @@ fs.realpathSync = function realpathSync(p, options) {
17221722
};
17231723

17241724

1725+
fs.realpathSync.native = function(path, options) {
1726+
options = getOptions(options, {});
1727+
handleError((path = getPathFromURL(path)));
1728+
nullCheck(path);
1729+
return binding.realpath(path, options.encoding);
1730+
};
1731+
1732+
17251733
fs.realpath = function realpath(p, options, callback) {
17261734
callback = maybeCallback(typeof options === 'function' ? options : callback);
17271735
if (!options)
@@ -1858,6 +1866,18 @@ fs.realpath = function realpath(p, options, callback) {
18581866
}
18591867
};
18601868

1869+
1870+
fs.realpath.native = function(path, options, callback) {
1871+
callback = maybeCallback(callback || options);
1872+
options = getOptions(options, {});
1873+
if (handleError((path = getPathFromURL(path)), callback)) return;
1874+
if (!nullCheck(path, callback)) return;
1875+
const req = new FSReqWrap();
1876+
req.oncomplete = callback;
1877+
return binding.realpath(path, options.encoding, req);
1878+
};
1879+
1880+
18611881
fs.mkdtemp = function(prefix, options, callback) {
18621882
callback = makeCallback(typeof options === 'function' ? options : callback);
18631883
options = getOptions(options, {});

src/node_file.cc

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -539,12 +539,17 @@ static void InternalModuleReadFile(const FunctionCallbackInfo<Value>& args) {
539539
start = 3; // Skip UTF-8 BOM.
540540
}
541541

542-
Local<String> chars_string =
543-
String::NewFromUtf8(env->isolate(),
544-
&chars[start],
545-
String::kNormalString,
546-
offset - start);
547-
args.GetReturnValue().Set(chars_string);
542+
const size_t size = offset - start;
543+
if (size == 0) {
544+
args.GetReturnValue().SetEmptyString();
545+
} else {
546+
Local<String> chars_string =
547+
String::NewFromUtf8(env->isolate(),
548+
&chars[start],
549+
String::kNormalString,
550+
size);
551+
args.GetReturnValue().Set(chars_string);
552+
}
548553
}
549554

550555
// Used to speed up module loading. Returns 0 if the path refers to
@@ -851,24 +856,15 @@ static void MKDir(const FunctionCallbackInfo<Value>& args) {
851856
}
852857

853858
static void RealPath(const FunctionCallbackInfo<Value>& args) {
859+
CHECK_GE(args.Length(), 2);
854860
Environment* env = Environment::GetCurrent(args);
855-
856-
const int argc = args.Length();
857-
858-
if (argc < 1)
859-
return TYPE_ERROR("path required");
860-
861861
BufferValue path(env->isolate(), args[0]);
862862
ASSERT_PATH(path)
863863

864864
const enum encoding encoding = ParseEncoding(env->isolate(), args[1], UTF8);
865865

866-
Local<Value> callback = Null(env->isolate());
867-
if (argc == 3)
868-
callback = args[2];
869-
870-
if (callback->IsObject()) {
871-
ASYNC_CALL(realpath, callback, encoding, *path);
866+
if (args[2]->IsObject()) {
867+
ASYNC_CALL(realpath, args[2], encoding, *path);
872868
} else {
873869
SYNC_CALL(realpath, *path, *path);
874870
const char* link_path = static_cast<const char*>(SYNC_REQ.ptr);

test/fixtures/empty-with-bom.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const fs = require('fs');
5+
6+
if (!common.isOSX) common.skip('MacOS-only test.');
7+
8+
assert.strictEqual(fs.realpathSync.native('/users'), '/Users');
9+
fs.realpath.native('/users', common.mustCall((err, res) => {
10+
assert.ifError(err);
11+
assert.strictEqual(res, '/Users');
12+
}));

0 commit comments

Comments
 (0)