Last change
on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | "use strict";
|
---|
2 | // Here we mock the global `process` variable in case we are not in Node's environment.
|
---|
3 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
4 | exports.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 | */
|
---|
15 | var maybeReturnProcess = function () {
|
---|
16 | if (typeof process !== 'undefined') {
|
---|
17 | return process;
|
---|
18 | }
|
---|
19 | try {
|
---|
20 | return require('process');
|
---|
21 | }
|
---|
22 | catch (_a) {
|
---|
23 | return undefined;
|
---|
24 | }
|
---|
25 | };
|
---|
26 | function createProcess() {
|
---|
27 | var p = maybeReturnProcess() || {};
|
---|
28 | if (!p.getuid)
|
---|
29 | p.getuid = function () { return 0; };
|
---|
30 | if (!p.getgid)
|
---|
31 | p.getgid = function () { return 0; };
|
---|
32 | if (!p.cwd)
|
---|
33 | p.cwd = function () { return '/'; };
|
---|
34 | if (!p.nextTick)
|
---|
35 | p.nextTick = require('./setImmediate').default;
|
---|
36 | if (!p.emitWarning)
|
---|
37 | p.emitWarning = function (message, type) {
|
---|
38 | // tslint:disable-next-line:no-console
|
---|
39 | console.warn("" + type + (type ? ': ' : '') + message);
|
---|
40 | };
|
---|
41 | if (!p.env)
|
---|
42 | p.env = {};
|
---|
43 | return p;
|
---|
44 | }
|
---|
45 | exports.createProcess = createProcess;
|
---|
46 | exports.default = createProcess();
|
---|
Note:
See
TracBrowser
for help on using the repository browser.