File tree Expand file tree Collapse file tree 4 files changed +29
-3
lines changed Expand file tree Collapse file tree 4 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -139,3 +139,11 @@ you get from `require('fs')`. Here are some things this function does:
139139 ```
140140
141141 - Adds constants ` fs.constants ` , ` fs.F_OK ` , etc.
142+
143+ ## Experimental fs.promise api warnings
144+
145+ Supress warnings when using the promise api of fs by setting
146+
147+ ``` js
148+ process .env [' SUPPRESS_EXPERIMENTAL_PROMISE_WARNINGS' ] = true ;
149+ ```
Original file line number Diff line number Diff line change 1- import _process , { createProcess } from '../process' ;
1+ import _process , { createProcess , SUPPRESS_EXPERIMENTAL_PROMISE_WARNINGS } from '../process' ;
22
33describe ( 'process' , ( ) => {
44 describe ( 'createProcess' , ( ) => {
@@ -17,5 +17,15 @@ describe('process', () => {
1717 expect ( typeof proc . nextTick ) . toBe ( 'function' ) ;
1818 proc . nextTick ( done ) ;
1919 } ) ;
20+ it ( '.env' , ( ) => {
21+ expect ( typeof proc . env ) . toBe ( 'object' ) ;
22+ expect ( ! ! proc . env [ SUPPRESS_EXPERIMENTAL_PROMISE_WARNINGS ] ) . toBe ( false ) ;
23+ } ) ;
24+ } ) ;
25+ test ( 'createProcess with env variable' , ( ) => {
26+ process . env [ SUPPRESS_EXPERIMENTAL_PROMISE_WARNINGS ] = 'true' ;
27+ const proc = createProcess ( ) ;
28+ expect ( ! ! proc . env [ SUPPRESS_EXPERIMENTAL_PROMISE_WARNINGS ] ) . toBe ( true ) ;
29+ delete process . env [ SUPPRESS_EXPERIMENTAL_PROMISE_WARNINGS ] ;
2030 } ) ;
2131} ) ;
Original file line number Diff line number Diff line change 11// Here we mock the global `process` variable in case we are not in Node's environment.
22
3+ export type SUPPRESS_EXPERIMENTAL_PROMISE_WARNINGS = 'SUPPRESS_EXPERIMENTAL_PROMISE_WARNINGS' ;
4+ export const SUPPRESS_EXPERIMENTAL_PROMISE_WARNINGS : SUPPRESS_EXPERIMENTAL_PROMISE_WARNINGS =
5+ 'SUPPRESS_EXPERIMENTAL_PROMISE_WARNINGS' ;
6+
37export interface IProcess {
48 getuid ( ) : number ;
59 getgid ( ) : number ;
610 cwd ( ) : string ;
711 platform : string ;
812 nextTick : ( callback : ( ...args ) => void , ...args ) => void ;
13+ env : {
14+ [ SUPPRESS_EXPERIMENTAL_PROMISE_WARNINGS ] ?: boolean ;
15+ } ;
916}
1017
1118export function createProcess ( p : IProcess = process ) : IProcess {
@@ -20,6 +27,7 @@ export function createProcess(p: IProcess = process): IProcess {
2027 if ( ! p . getgid ) p . getgid = ( ) => 0 ;
2128 if ( ! p . cwd ) p . cwd = ( ) => '/' ;
2229 if ( ! p . nextTick ) p . nextTick = require ( './setImmediate' ) . default ;
30+ if ( ! p . env ) p . env = { } ;
2331 return p ;
2432}
2533
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import Stats, { TStatNumber } from './Stats';
44import Dirent from './Dirent' ;
55import { Buffer } from 'buffer' ;
66import setImmediate from './setImmediate' ;
7- import process from './process' ;
7+ import process , { SUPPRESS_EXPERIMENTAL_PROMISE_WARNINGS } from './process' ;
88import setTimeoutUnref , { TSetTimeout } from './setTimeoutUnref' ;
99import { Readable , Writable } from 'stream' ;
1010import { constants } from './constants' ;
@@ -516,7 +516,7 @@ function validateGid(gid: number) {
516516
517517// ---------------------------------------- Volume
518518
519- let promisesWarn = true ;
519+ let promisesWarn = process [ SUPPRESS_EXPERIMENTAL_PROMISE_WARNINGS ] ? false : true ;
520520
521521/**
522522 * `Volume` represents a file system.
You can’t perform that action at this time.
0 commit comments