Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3191f30

Browse filesBrowse files
cjihrigMylesBorins
authored andcommitted
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>
1 parent bc4d4f0 commit 3191f30
Copy full SHA for 3191f30
Expand file treeCollapse file tree

25 files changed

+50
-37
lines changed
Open diff view settings
Collapse file

‎benchmark/fs/bench-stat-promise.js‎

Copy file name to clipboardExpand all lines: benchmark/fs/bench-stat-promise.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const common = require('../common');
4-
const fsPromises = require('fs/promises');
4+
const fsPromises = require('fs').promises;
55

66
const bench = common.createBenchmark(main, {
77
n: [20e4],
Collapse file

‎doc/api/fs.md‎

Copy file name to clipboardExpand all lines: doc/api/fs.md
+2-2Lines changed: 2 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -3382,9 +3382,9 @@ Synchronous versions of [`fs.write()`][]. Returns the number of bytes written.
33823382

33833383
> Stability: 1 - Experimental
33843384
3385-
The `fs/promises` API provides an alternative set of asynchronous file system
3385+
The `fs.promises` API provides an alternative set of asynchronous file system
33863386
methods that return `Promise` objects rather than using callbacks. The
3387-
API is accessible via `require('fs/promises')`.
3387+
API is accessible via `require('fs').promises`.
33883388

33893389
### class: FileHandle
33903390
<!-- YAML
Collapse file

‎lib/fs.js‎

Copy file name to clipboardExpand all lines: lib/fs.js
+17-1Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ const { Readable, Writable } = require('stream');
4545
const EventEmitter = require('events');
4646
const { FSReqWrap, statValues, kFsStatsFieldsLength } = binding;
4747
const { FSEvent } = process.binding('fs_event_wrap');
48-
const internalFS = require('internal/fs');
48+
const promises = require('internal/fs/promises');
49+
const internalFS = require('internal/fs/utils');
4950
const { getPathFromURL } = require('internal/url');
5051
const internalUtil = require('internal/util');
5152
const {
@@ -72,6 +73,21 @@ const {
7273
CHAR_BACKWARD_SLASH,
7374
} = require('internal/constants');
7475

76+
let warn = true;
77+
78+
Object.defineProperty(fs, 'promises', {
79+
configurable: true,
80+
enumerable: true,
81+
get() {
82+
if (warn) {
83+
warn = false;
84+
process.emitWarning('The fs.promises API is experimental',
85+
'ExperimentalWarning');
86+
}
87+
return promises;
88+
}
89+
});
90+
7591
Object.defineProperty(exports, 'constants', {
7692
configurable: false,
7793
enumerable: true,
Collapse file
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
'use strict';
22

3-
process.emitWarning('The fs/promises API is experimental',
4-
'ExperimentalWarning');
5-
63
const {
74
F_OK,
85
O_SYMLINK,
@@ -37,7 +34,7 @@ const {
3734
validateOffsetLengthWrite,
3835
validatePath,
3936
validateUint32
40-
} = require('internal/fs');
37+
} = require('internal/fs/utils');
4138
const pathModule = require('path');
4239

4340
const kHandle = Symbol('handle');
Collapse file

‎lib/internal/modules/cjs/loader.js‎

Copy file name to clipboardExpand all lines: lib/internal/modules/cjs/loader.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const { getURLFromFilePath } = require('internal/url');
2828
const vm = require('vm');
2929
const assert = require('assert').ok;
3030
const fs = require('fs');
31-
const internalFS = require('internal/fs');
31+
const internalFS = require('internal/fs/utils');
3232
const path = require('path');
3333
const {
3434
internalModuleReadJSON,
Collapse file

‎lib/internal/modules/esm/default_resolve.js‎

Copy file name to clipboardExpand all lines: lib/internal/modules/esm/default_resolve.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const { URL } = require('url');
44
const CJSmodule = require('internal/modules/cjs/loader');
5-
const internalFS = require('internal/fs');
5+
const internalFS = require('internal/fs/utils');
66
const { NativeModule, internalBinding } = require('internal/bootstrap/loaders');
77
const { extname } = require('path');
88
const { realpathSync } = require('fs');
Collapse file

‎lib/internal/process/stdio.js‎

Copy file name to clipboardExpand all lines: lib/internal/process/stdio.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ function createWritableStdioStream(fd) {
158158
break;
159159

160160
case 'FILE':
161-
var fs = require('internal/fs');
161+
var fs = require('internal/fs/utils');
162162
stream = new fs.SyncWriteStream(fd, { autoClose: false });
163163
stream._type = 'fs';
164164
break;
Collapse file

‎node.gyp‎

Copy file name to clipboardExpand all lines: node.gyp
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
'lib/domain.js',
4040
'lib/events.js',
4141
'lib/fs.js',
42-
'lib/fs/promises.js',
4342
'lib/http.js',
4443
'lib/http2.js',
4544
'lib/_http_agent.js',
@@ -103,7 +102,8 @@
103102
'lib/internal/errors.js',
104103
'lib/internal/fixed_queue.js',
105104
'lib/internal/freelist.js',
106-
'lib/internal/fs.js',
105+
'lib/internal/fs/promises.js',
106+
'lib/internal/fs/utils.js',
107107
'lib/internal/http.js',
108108
'lib/internal/inspector_async_hook.js',
109109
'lib/internal/linkedlist.js',
Collapse file

‎test/parallel/test-fs-filehandle.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-filehandle.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const common = require('../common');
55
const assert = require('assert');
66
const path = require('path');
77
const fs = process.binding('fs');
8-
const { stringToFlags } = require('internal/fs');
8+
const { stringToFlags } = require('internal/fs/utils');
99

1010
// Verifies that the FileHandle object is garbage collected and that a
1111
// warning is emitted if it is not closed.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.