Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
763627a
doc: add more missing backticks
vsemozhetbyt Apr 29, 2018
f6c6950
doc: remove squash guideline from onboarding doc
Trott Apr 30, 2018
ca7e3e4
doc: add squash guideline to pull-requests doc
Trott Apr 30, 2018
8fbd0d3
benchmark: fix next-tick-depth
apapirovski May 2, 2018
a8fc842
doc: add http.ClientRequest maxHeadersCount
darai0512 Apr 23, 2018
f6d37f2
tools: fix TypeError from `test.py --time`
richardlau Apr 27, 2018
bd8e626
doc: update writing-and-running-benchmarks.md
xsbchen Apr 28, 2018
a8ffbbe
timers: named anonymous functions
js-kyle Apr 29, 2018
147ced4
child_process: name anonymous functions
SerayaEryn Apr 29, 2018
3d2a7fe
test: remove unnecessary strictEqual() argument from remoteClose()
dayloryanes Apr 26, 2018
f438438
test: use fs.copyFileSync()
richardlau Apr 26, 2018
1de252a
doc: add missing periods in documentation.md
vsemozhetbyt May 2, 2018
52e6ef0
events: optimize condition for optimal scenario
apapirovski May 1, 2018
dbf3089
util: improve spliceOne perf
apapirovski May 1, 2018
2d26f55
doc: update cli flag in crypto.md
shobhitchittora Apr 29, 2018
b15c793
doc: synchronize argument names for appendFile()
Trott May 3, 2018
43ba7a6
util: named anonymous functions
possumwork Apr 29, 2018
81584d1
lib: named anonymous functions
possumwork Apr 30, 2018
7e87142
doc: update Collaborator Guide reference
Trott May 2, 2018
36d93da
doc: cleanup n-api.md doc
mhdawson Apr 30, 2018
a5467bf
src: remove `kFlagNoShutdown` flag
addaleax Apr 28, 2018
fd67e9e
src: access `ContextifyContext*` more directly in property cbs
addaleax May 1, 2018
98a39e3
src: refactor `BaseObject` internal field management
addaleax May 1, 2018
18bb358
doc: update examples for fs.access()
BeniCheni May 1, 2018
d329778
n-api: make test_error functions static
Apr 27, 2018
c66ba19
crypto: allocate more memory for cipher.update()
yhwang Apr 26, 2018
ff148b9
deps: patch V8 to 6.6.346.27
MylesBorins May 2, 2018
8c0cf1e
doc: fix mkdtemp() documentation
Trott May 4, 2018
0254698
doc: document using `domain` in REPL
AyushG3112 Apr 28, 2018
d7dcc0a
test: add fs/promises filehandle stat test
May 3, 2018
064b061
repl: add spaces to load/save messages
cjihrig May 5, 2018
5248cd7
test: rename misnamed test
Trott May 5, 2018
6966c04
test: fix up N-API error test
May 3, 2018
ae33fa3
src: fix inconsistency in extern declaration
hashseed Apr 30, 2018
3da63ff
build: check for different deprecation signatures
BridgeAR Apr 28, 2018
34f73ec
doc: fix manpage warning
kapouer Apr 28, 2018
b9dfaac
https: defines maxHeadersCount in the constructor
darai0512 Apr 22, 2018
1e2ce1d
src: removed unnecessary prototypes from Environment::SetProtoMethod
brandontruggles Apr 26, 2018
0642b6f
test: fix common.canCreateSymLink() on non-Windows
May 4, 2018
f508574
lib: expose FixedQueue internally and fix nextTick bug
apapirovski May 2, 2018
fc311f2
tls: cleanup onhandshakestart callback
apapirovski May 2, 2018
d0d0547
benchmark: track exec time in next-tick-exec
apapirovski May 2, 2018
0f75c08
doc: fix N-API property descriptor documentation
Apr 30, 2018
31dfb0a
doc: updates crypto doc with openssl list -cipher-algorithms
shobhitchittora May 3, 2018
d866984
tls: remove sharedCreds in Server constructor
danbev May 3, 2018
6e2a22f
errors: remove dead code
BridgeAR May 2, 2018
755e88f
http2: rename http2_state class to Http2State
danbev Apr 30, 2018
59ed6c0
doc: add snake_case section for C-like structs
danbev May 2, 2018
ea6af3b
src: add public API to expose the main V8 Platform
helloshuangzi May 1, 2018
aef4f80
doc: update one more command in crypto.md
shobhitchittora May 3, 2018
c06821a
Revert "stream: prevent 'end' to be emitted after 'error'"
mscdex May 1, 2018
b06d90d
url: fix WHATWG host formatting error
peakji May 3, 2018
a068808
tools: remove redundant code in doc/html.js
vsemozhetbyt May 4, 2018
883d03b
doc: clearer doc-only deprecations
BridgeAR Apr 28, 2018
702ba74
test: fix buffer writes on mips
BridgeAR Apr 27, 2018
849d10d
test: fix test-cli-node-options.js on mips
BridgeAR Apr 28, 2018
f8ddf7b
doc: add parameters for Http2Session:stream event
ryzokuken May 5, 2018
2bddd24
doc: edit text for DEP0104
Trott May 4, 2018
b7e8249
doc: edit text for DEP0101
Trott May 4, 2018
6011c21
doc: edit text for DEP0012
Trott May 4, 2018
6a18a42
doc: edit text for DEP0094
Trott May 4, 2018
7d9234b
doc: fix text for DEP0085
Trott May 4, 2018
bc8d08d
doc: edit text for DEP0082
Trott May 4, 2018
f59619a
doc: fix minor typographical error in DEP0079 text
Trott May 4, 2018
17f9da5
doc: minor edit to DEP0065
Trott May 4, 2018
4ce7026
doc: edit text for DEP0013
Trott May 4, 2018
b0d6edc
doc: edit text about revoking deprecations
Trott May 4, 2018
dc8c8ef
doc: excise "periodically" before "emit events"
jeswcollins May 7, 2018
9ba8ab0
doc: update "Who to cc..." in COLLABORATOR_GUIDE
vsemozhetbyt May 6, 2018
8ed803d
fs: move fs/promises to fs.promises
cjihrig May 3, 2018
381fccd
doc: add trace category for fs sync methods
chinhuang007 May 4, 2018
fa0565e
console: make console.table() use colored inspect
makenowjust May 4, 2018
e2fb920
doc: move tunniclm to Emeritus
Trott May 5, 2018
acf3019
fs: remove broken code in promises/write
ChALkeR Apr 29, 2018
88f9c38
fs: fchmod->fchown in promises/lchown
ChALkeR Apr 29, 2018
69a8a65
doc: clarify `this` in event listeners
dagolinuxoid May 5, 2018
7b4e815
tools: add v10 to alternative version docs menu
vsemozhetbyt May 7, 2018
85babad
test: use common.canCreateSymLink() consistently
cjihrig May 5, 2018
aad2c23
tools: add eslint check for skipIfEslintMissing
richardlau Apr 27, 2018
7bf23cf
doc: match console.count()/countReset() signatures
Lambdac0re May 8, 2018
c7514a5
src: more automatic memory management in node_crypto.cc
addaleax Apr 23, 2018
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
Prev Previous commit
Next Next commit
fs: move fs/promises to fs.promises
PR-URL: #20504
Refs: nodejs/TSC#389
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
  • Loading branch information
cjihrig authored and MylesBorins committed May 8, 2018
commit 8ed803dd107c61dbc0c14896576d70385b9f1027
2 changes: 1 addition & 1 deletion benchmark/fs/bench-stat-promise.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const common = require('../common');
const fsPromises = require('fs/promises');
const fsPromises = require('fs').promises;

const bench = common.createBenchmark(main, {
n: [20e4],
Expand Down
4 changes: 2 additions & 2 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -3382,9 +3382,9 @@ Synchronous versions of [`fs.write()`][]. Returns the number of bytes written.

> Stability: 1 - Experimental

The `fs/promises` API provides an alternative set of asynchronous file system
The `fs.promises` API provides an alternative set of asynchronous file system
methods that return `Promise` objects rather than using callbacks. The
API is accessible via `require('fs/promises')`.
API is accessible via `require('fs').promises`.

### class: FileHandle
<!-- YAML
Expand Down
18 changes: 17 additions & 1 deletion lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ const { Readable, Writable } = require('stream');
const EventEmitter = require('events');
const { FSReqWrap, statValues, kFsStatsFieldsLength } = binding;
const { FSEvent } = process.binding('fs_event_wrap');
const internalFS = require('internal/fs');
const promises = require('internal/fs/promises');
const internalFS = require('internal/fs/utils');
const { getPathFromURL } = require('internal/url');
const internalUtil = require('internal/util');
const {
Expand All @@ -72,6 +73,21 @@ const {
CHAR_BACKWARD_SLASH,
} = require('internal/constants');

let warn = true;

Object.defineProperty(fs, 'promises', {
configurable: true,
enumerable: true,
get() {
if (warn) {
warn = false;
process.emitWarning('The fs.promises API is experimental',
'ExperimentalWarning');
}
return promises;
}
});

Object.defineProperty(exports, 'constants', {
configurable: false,
enumerable: true,
Expand Down
5 changes: 1 addition & 4 deletions lib/fs/promises.js → lib/internal/fs/promises.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
'use strict';

process.emitWarning('The fs/promises API is experimental',
'ExperimentalWarning');

const {
F_OK,
O_SYMLINK,
Expand Down Expand Up @@ -37,7 +34,7 @@ const {
validateOffsetLengthWrite,
validatePath,
validateUint32
} = require('internal/fs');
} = require('internal/fs/utils');
const pathModule = require('path');

const kHandle = Symbol('handle');
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/internal/modules/cjs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const { getURLFromFilePath } = require('internal/url');
const vm = require('vm');
const assert = require('assert').ok;
const fs = require('fs');
const internalFS = require('internal/fs');
const internalFS = require('internal/fs/utils');
const path = require('path');
const {
internalModuleReadJSON,
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/modules/esm/default_resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const { URL } = require('url');
const CJSmodule = require('internal/modules/cjs/loader');
const internalFS = require('internal/fs');
const internalFS = require('internal/fs/utils');
const { NativeModule, internalBinding } = require('internal/bootstrap/loaders');
const { extname } = require('path');
const { realpathSync } = require('fs');
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/process/stdio.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function createWritableStdioStream(fd) {
break;

case 'FILE':
var fs = require('internal/fs');
var fs = require('internal/fs/utils');
stream = new fs.SyncWriteStream(fd, { autoClose: false });
stream._type = 'fs';
break;
Expand Down
4 changes: 2 additions & 2 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
'lib/domain.js',
'lib/events.js',
'lib/fs.js',
'lib/fs/promises.js',
'lib/http.js',
'lib/http2.js',
'lib/_http_agent.js',
Expand Down Expand Up @@ -103,7 +102,8 @@
'lib/internal/errors.js',
'lib/internal/fixed_queue.js',
'lib/internal/freelist.js',
'lib/internal/fs.js',
'lib/internal/fs/promises.js',
'lib/internal/fs/utils.js',
'lib/internal/http.js',
'lib/internal/inspector_async_hook.js',
'lib/internal/linkedlist.js',
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-fs-filehandle.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const common = require('../common');
const assert = require('assert');
const path = require('path');
const fs = process.binding('fs');
const { stringToFlags } = require('internal/fs');
const { stringToFlags } = require('internal/fs/utils');

// Verifies that the FileHandle object is garbage collected and that a
// warning is emitted if it is not closed.
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-fs-open-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const O_DSYNC = fs.constants.O_DSYNC || 0;
const O_TRUNC = fs.constants.O_TRUNC || 0;
const O_WRONLY = fs.constants.O_WRONLY || 0;

const { stringToFlags } = require('internal/fs');
const { stringToFlags } = require('internal/fs/utils');

assert.strictEqual(stringToFlags('r'), O_RDONLY);
assert.strictEqual(stringToFlags('r+'), O_RDWR);
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-fs-promises-file-handle-append-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

const common = require('../common');

// The following tests validate base functionality for the fs/promises
// The following tests validate base functionality for the fs.promises
// FileHandle.appendFile method.

const fs = require('fs');
const { open } = require('fs/promises');
const { open } = fs.promises;
const path = require('path');
const tmpdir = require('../common/tmpdir');
const assert = require('assert');
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-fs-promises-file-handle-chmod.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

const common = require('../common');

// The following tests validate base functionality for the fs/promises
// The following tests validate base functionality for the fs.promises
// FileHandle.chmod method.

const fs = require('fs');
const { open } = require('fs/promises');
const { open } = fs.promises;
const path = require('path');
const tmpdir = require('../common/tmpdir');
const assert = require('assert');
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-fs-promises-file-handle-read.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

const common = require('../common');

// The following tests validate base functionality for the fs/promises
// The following tests validate base functionality for the fs.promises
// FileHandle.read method.

const fs = require('fs');
const { open } = require('fs/promises');
const { open } = fs.promises;
const path = require('path');
const tmpdir = require('../common/tmpdir');
const assert = require('assert');
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-fs-promises-file-handle-readFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

const common = require('../common');

// The following tests validate base functionality for the fs/promises
// The following tests validate base functionality for the fs.promises
// FileHandle.readFile method.

const fs = require('fs');
const { open } = require('fs/promises');
const { open } = fs.promises;
const path = require('path');
const tmpdir = require('../common/tmpdir');
const assert = require('assert');
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-fs-promises-file-handle-stat.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

const common = require('../common');

// The following tests validate base functionality for the fs/promises
// The following tests validate base functionality for the fs.promises
// FileHandle.stat method.

const { open } = require('fs/promises');
const { open } = require('fs').promises;
const path = require('path');
const tmpdir = require('../common/tmpdir');
const assert = require('assert');
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-fs-promises-file-handle-write.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

const common = require('../common');

// The following tests validate base functionality for the fs/promises
// The following tests validate base functionality for the fs.promises
// FileHandle.read method.

const fs = require('fs');
const { open } = require('fs/promises');
const { open } = fs.promises;
const path = require('path');
const tmpdir = require('../common/tmpdir');
const assert = require('assert');
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-fs-promises-file-handle-writeFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

const common = require('../common');

// The following tests validate base functionality for the fs/promises
// The following tests validate base functionality for the fs.promises
// FileHandle.readFile method.

const fs = require('fs');
const { open } = require('fs/promises');
const { open } = fs.promises;
const path = require('path');
const tmpdir = require('../common/tmpdir');
const assert = require('assert');
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-fs-promises-readfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const common = require('../common');

const assert = require('assert');
const path = require('path');
const { writeFile, readFile } = require('fs/promises');
const { writeFile, readFile } = require('fs').promises;
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-fs-promises-writefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const common = require('../common');
const fs = require('fs');
const fsPromises = require('fs/promises');
const fsPromises = fs.promises;
const path = require('path');
const tmpdir = require('../common/tmpdir');
const assert = require('assert');
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-fs-promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const assert = require('assert');
const tmpdir = require('../common/tmpdir');
const fixtures = require('../common/fixtures');
const path = require('path');
const fsPromises = require('fs/promises');
const fsPromises = require('fs').promises;
const {
access,
chmod,
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-fs-syncwritestream.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const stream = require('stream');
const fs = require('fs');
const path = require('path');

// require('internal/fs').SyncWriteStream is used as a stdio implementation
// when stdout/stderr point to files.
// require('internal/fs/utils').SyncWriteStream is used as a stdio
// implementation when stdout/stderr point to files.

if (process.argv[2] === 'child') {
// Note: Calling console.log() is part of this test as it exercises the
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-internal-fs-syncwritestream.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const common = require('../common');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const SyncWriteStream = require('internal/fs').SyncWriteStream;
const SyncWriteStream = require('internal/fs/utils').SyncWriteStream;

const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-internal-fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict';

const common = require('../common');
const fs = require('internal/fs');
const fs = require('internal/fs/utils');

// Valid encodings and no args should not throw.
fs.assertEncoding();
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-async-wrap-getasyncid.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const common = require('../common');
const assert = require('assert');
const fs = require('fs');
const fsPromises = require('fs/promises');
const fsPromises = fs.promises;
const net = require('net');
const providers = Object.assign({}, process.binding('async_wrap').Providers);
const fixtures = require('../common/fixtures');
Expand Down