From 7a55e34ef4f84e5f982ebaaee4532b774abee3ec Mon Sep 17 00:00:00 2001 From: James M Snell Date: Mon, 26 Dec 2016 18:38:05 -0800 Subject: [PATCH] fs: runtime deprecation for fs.SyncWriteStream MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This API was never intended to be made public and was docs-only deprecated in Node.js 6.x. This upgrades to a runtime deprecation for Node.js 8.0.0 PR-URL: https://github.com/nodejs/node/pull/10467 Reviewed-By: Michaƫl Zasso Reviewed-By: Colin Ihrig Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Evan Lucas Reviewed-By: Michael Dawson Reviewed-By: Matteo Collina --- doc/api/deprecations.md | 4 ++-- lib/fs.js | 16 +++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 1549d49872a4c0..1ee1c40ee882ad 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -509,10 +509,10 @@ The [`util._extend()`][] API has been deprecated. ### DEP0061: fs.SyncWriteStream -Type: Documentation-only +Type: Runtime The `fs.SyncWriteStream` class was never intended to be a publicly accessible -API. +API. No alternative API is available. Please use a userland alternative. ### DEP0062: node --debug diff --git a/lib/fs.js b/lib/fs.js index c05e9e592d0c7c..d45bd82df7036c 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -17,9 +17,9 @@ const FSReqWrap = binding.FSReqWrap; const FSEvent = process.binding('fs_event_wrap').FSEvent; const internalFS = require('internal/fs'); const internalURL = require('internal/url'); +const internalUtil = require('internal/util'); const assertEncoding = internalFS.assertEncoding; const stringToFlags = internalFS.stringToFlags; -const SyncWriteStream = internalFS.SyncWriteStream; const getPathFromURL = internalURL.getPathFromURL; Object.defineProperty(exports, 'constants', { @@ -2024,12 +2024,14 @@ WriteStream.prototype.close = ReadStream.prototype.close; WriteStream.prototype.destroySoon = WriteStream.prototype.end; // SyncWriteStream is internal. DO NOT USE. -// todo(jasnell): "Docs-only" deprecation for now. This was never documented -// so there's no documentation to modify. In the future, add a runtime -// deprecation. -// Deprecation ID: DEP0061 +// This undocumented API was never intended to be made public. +var SyncWriteStream = internalFS.SyncWriteStream; Object.defineProperty(fs, 'SyncWriteStream', { configurable: true, - writable: true, - value: SyncWriteStream + get: internalUtil.deprecate(() => { + return SyncWriteStream; + }, 'fs.SyncWriteStream is deprecated.', 'DEP0061'), + set: internalUtil.deprecate((val) => { + SyncWriteStream = val; + }, 'fs.SyncWriteStream is deprecated.', 'DEP0061') });