diff --git a/src/process.ts b/src/process.ts index 5656227f..b43e74ff 100644 --- a/src/process.ts +++ b/src/process.ts @@ -6,6 +6,7 @@ export interface IProcess { cwd(): string; platform: string; nextTick: (callback: (...args) => void, ...args) => void; + emitWarning: (message: string, type: string) => void; env: { MEMFS_DONT_WARN?: boolean; }; @@ -23,6 +24,11 @@ export function createProcess(p: IProcess = process): IProcess { if (!p.getgid) p.getgid = () => 0; if (!p.cwd) p.cwd = () => '/'; if (!p.nextTick) p.nextTick = require('./setImmediate').default; + if (!p.emitWarning) + p.emitWarning = (message, type) => { + // tslint:disable-next-line:no-console + console.warn(`${type}${type ? ': ' : ''}${message}`); + }; if (!p.env) p.env = {}; return p; } diff --git a/src/volume.ts b/src/volume.ts index 3c377c5f..0f41091f 100644 --- a/src/volume.ts +++ b/src/volume.ts @@ -582,7 +582,7 @@ export class Volume { get promises() { if (promisesWarn) { promisesWarn = false; - require('process').emitWarning('The fs.promises API is experimental', 'ExperimentalWarning'); + process.emitWarning('The fs.promises API is experimental', 'ExperimentalWarning'); } if (this.promisesApi === null) throw new Error('Promise is not supported in this environment.'); return this.promisesApi;