1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.url = exports.path = exports.os = exports.https = exports.fs = exports.child_process = void 0;
|
7 |
|
8 | var realFs = _interopRequireWildcard(require("fs"));
|
9 |
|
10 | var node_child_process = _interopRequireWildcard(require("child_process"));
|
11 |
|
12 | var node_https = _interopRequireWildcard(require("https"));
|
13 |
|
14 | var node_os = _interopRequireWildcard(require("os"));
|
15 |
|
16 | var node_path = _interopRequireWildcard(require("path"));
|
17 |
|
18 | var node_url = _interopRequireWildcard(require("url"));
|
19 |
|
20 | var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
21 |
|
22 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23 |
|
24 | function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
25 |
|
26 | function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
27 |
|
28 | const child_process = {
|
29 | exec: node_child_process.exec,
|
30 | execP: function (command, options) {
|
31 | return new Promise((res, rej) => {
|
32 | node_child_process.exec(command, options, (err, stdout, stderr) => {
|
33 | if (err) {
|
34 | rej(err);
|
35 | } else {
|
36 | res({
|
37 | stdout: Buffer.from(stdout),
|
38 | stderr: Buffer.from(stderr)
|
39 | });
|
40 | }
|
41 | });
|
42 | });
|
43 | },
|
44 | execFileP: function (command, argsOrOptions, options) {
|
45 | let _args;
|
46 |
|
47 | let _opts;
|
48 |
|
49 | if (Array.isArray(argsOrOptions)) {
|
50 | _args = argsOrOptions;
|
51 | _opts = options ? options : {};
|
52 | } else {
|
53 | _args = [];
|
54 | _opts = argsOrOptions ? argsOrOptions : {};
|
55 | }
|
56 |
|
57 | return new Promise((res, rej) => {
|
58 | node_child_process.execFile(command, _args, _opts, (err, stdout, stderr) => {
|
59 | if (err) {
|
60 | rej(err);
|
61 | } else {
|
62 | res({
|
63 | stdout: typeof stdout === 'string' ? Buffer.from(stdout) : stdout,
|
64 | stderr: typeof stderr === 'string' ? Buffer.from(stderr) : stderr
|
65 | });
|
66 | }
|
67 | });
|
68 | });
|
69 | },
|
70 | spawnP: function (command, args, options) {
|
71 | return new Promise((res, rej) => {
|
72 | const process = node_child_process.spawn(command, args, options);
|
73 | let stderr = '';
|
74 | let stdout = '';
|
75 | process.stdout.on('data', chunk => stdout += chunk);
|
76 | process.stderr.on('data', chunk => stderr += chunk);
|
77 | process.on('close', exitCode => {
|
78 | if (exitCode === 0) {
|
79 | res({
|
80 | stderr,
|
81 | stdout,
|
82 | exitCode
|
83 | });
|
84 | } else {
|
85 | rej({
|
86 | stderr,
|
87 | stdout,
|
88 | exitCode
|
89 | });
|
90 | }
|
91 | });
|
92 | });
|
93 | }
|
94 | };
|
95 | exports.child_process = child_process;
|
96 | const fs = {
|
97 | appendFile: _fsExtra.default.appendFile,
|
98 | close: _fsExtra.default.close,
|
99 | copy: _fsExtra.default.copy,
|
100 | copyFile: _fsExtra.default.copyFile,
|
101 | createReadStream: _fsExtra.default.createReadStream,
|
102 | createWriteStream: _fsExtra.default.createWriteStream,
|
103 | exists: _fsExtra.default.exists,
|
104 | existsSync: realFs.existsSync,
|
105 | mkdir: _fsExtra.default.mkdir,
|
106 | open: _fsExtra.default.open,
|
107 | readdir: _fsExtra.default.readdir,
|
108 | readFile: _fsExtra.default.readFile,
|
109 | readFileSync: _fsExtra.default.readFileSync,
|
110 | readJson: _fsExtra.default.readJson,
|
111 | rename: _fsExtra.default.rename,
|
112 | rmdir: _fsExtra.default.rmdir,
|
113 | stat: _fsExtra.default.stat,
|
114 | statSync: _fsExtra.default.statSync,
|
115 | Stats: _fsExtra.default.Stats,
|
116 | unlink: _fsExtra.default.unlink,
|
117 | writeFile: _fsExtra.default.writeFile,
|
118 | writeJson: _fsExtra.default.writeJson
|
119 | };
|
120 | exports.fs = fs;
|
121 | const https = node_https;
|
122 | exports.https = https;
|
123 | const os = node_os;
|
124 | exports.os = os;
|
125 | const path = node_path;
|
126 | exports.path = path;
|
127 | const url = node_url;
|
128 | exports.url = url; |
\ | No newline at end of file |