UNPKG

1.13 kBJavaScriptView Raw
1"use strict";
2// Here we mock the global `process` variable in case we are not in Node's environment.
3Object.defineProperty(exports, "__esModule", { value: true });
4exports.createProcess = void 0;
5/**
6 * Looks to return a `process` object, if one is available.
7 *
8 * The global `process` is returned if defined;
9 * otherwise `require('process')` is attempted.
10 *
11 * If that fails, `undefined` is returned.
12 *
13 * @return {IProcess | undefined}
14 */
15const maybeReturnProcess = () => {
16 if (typeof process !== 'undefined') {
17 return process;
18 }
19 try {
20 return require('process');
21 }
22 catch (_a) {
23 return undefined;
24 }
25};
26function createProcess() {
27 const p = maybeReturnProcess() || {};
28 if (!p.cwd)
29 p.cwd = () => '/';
30 if (!p.emitWarning)
31 p.emitWarning = (message, type) => {
32 // tslint:disable-next-line:no-console
33 console.warn(`${type}${type ? ': ' : ''}${message}`);
34 };
35 if (!p.env)
36 p.env = {};
37 return p;
38}
39exports.createProcess = createProcess;
40exports.default = createProcess();
41//# sourceMappingURL=process.js.map
\No newline at end of file