Skip to content

Commit

Permalink
fs: add fs/promises alias module
Browse files Browse the repository at this point in the history
PR-URL: nodejs#31553
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
  • Loading branch information
devsnek committed Feb 19, 2020
1 parent e6c2277 commit b8e4177
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -4237,7 +4237,7 @@ this API: [`fs.writev()`][].

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` or `require('fs/promises')`.

### class: `FileHandle`
<!-- YAML
Expand Down
3 changes: 3 additions & 0 deletions lib/fs/promises.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = require('internal/fs/promises').exports;
1 change: 1 addition & 0 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
'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
5 changes: 5 additions & 0 deletions test/es-module/test-esm-fs-promises.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import '../common/index.mjs';
import { stat } from 'fs/promises';

// Should not reject.
stat(new URL(import.meta.url));
6 changes: 6 additions & 0 deletions test/parallel/test-fs-promises-exists.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict';

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

assert.strictEqual(require('fs/promises'), require('fs').promises);

0 comments on commit b8e4177

Please sign in to comment.