From 68c5ee45a2e6b35211a166a50eecb54bbd4cb683 Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Thu, 22 Oct 2020 12:52:39 -0400 Subject: [PATCH] doc: update fs promise-based examples MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/nodejs/node/pull/34843 was cherry-picked onto `v12.x-staging` in 961844d25b but the `fs/promises` API, as used in the examples, is only available from Node.js 14. Change the added examples to use `require(fs).promises` instead. PR-URL: https://github.com/nodejs/node/pull/35760 Fixes: https://github.com/nodejs/node/issues/35740 Refs: https://github.com/nodejs/node/pull/34843 Reviewed-By: Antoine du Hamel Reviewed-By: Luigi Pinca Reviewed-By: Franziska Hinkelmann Reviewed-By: Ricky Zhou <0x19951125@gmail.com> Reviewed-By: Michaƫl Zasso Reviewed-By: Anto Aravinth --- doc/api/fs.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index f48f2e3b2ddf6a..c3d0b38ff18571 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -60,7 +60,7 @@ Promise-based operations return a `Promise` that is resolved when the asynchronous operation is complete. ```js -const fs = require('fs/promises'); +const fs = require('fs').promises; (async function(path) { try { @@ -106,7 +106,7 @@ fs.rename('/tmp/hello', '/tmp/world', (err) => { Or, use the promise-based API: ```js -const fs = require('fs/promises'); +const fs = require('fs').promises; (async function(from, to) { try {