@@ -43,7 +43,6 @@ const isWindows = process.platform === 'win32';
43
43
44
44
const DEBUG = process . env . NODE_DEBUG && / f s / . test ( process . env . NODE_DEBUG ) ;
45
45
const errnoException = util . _errnoException ;
46
- const printDeprecation = require ( 'internal/util' ) . printDeprecationMessage ;
47
46
48
47
function throwOptionsError ( options ) {
49
48
throw new TypeError ( 'Expected options to be either an object or a string, ' +
@@ -613,10 +612,14 @@ var readWarned = false;
613
612
fs . read = function ( fd , buffer , offset , length , position , callback ) {
614
613
if ( ! ( buffer instanceof Buffer ) ) {
615
614
// legacy string interface (fd, length, position, encoding, callback)
616
- readWarned = printDeprecation ( 'fs.read\'s legacy String interface ' +
617
- 'is deprecated. Use the Buffer API as ' +
618
- 'mentioned in the documentation instead.' ,
619
- readWarned ) ;
615
+ if ( ! readWarned ) {
616
+ readWarned = true ;
617
+ process . emitWarning (
618
+ 'fs.read\'s legacy String interface is deprecated. Use the Buffer ' +
619
+ 'API as mentioned in the documentation instead.' ,
620
+ 'DeprecationWarning' ) ;
621
+ }
622
+
620
623
const cb = arguments [ 4 ] ;
621
624
const encoding = arguments [ 3 ] ;
622
625
@@ -673,10 +676,13 @@ fs.readSync = function(fd, buffer, offset, length, position) {
673
676
674
677
if ( ! ( buffer instanceof Buffer ) ) {
675
678
// legacy string interface (fd, length, position, encoding, callback)
676
- readSyncWarned = printDeprecation ( 'fs.readSync\'s legacy String interface' +
677
- 'is deprecated. Use the Buffer API as ' +
678
- 'mentioned in the documentation instead.' ,
679
- readSyncWarned ) ;
679
+ if ( ! readSyncWarned ) {
680
+ readSyncWarned = true ;
681
+ process . emitWarning (
682
+ 'fs.readSync\'s legacy String interface is deprecated. Use the ' +
683
+ 'Buffer API as mentioned in the documentation instead.' ,
684
+ 'DeprecationWarning' ) ;
685
+ }
680
686
legacy = true ;
681
687
encoding = arguments [ 3 ] ;
682
688
0 commit comments