1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
13 | if (k2 === undefined) k2 = k;
|
14 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
15 | }) : (function(o, m, k, k2) {
|
16 | if (k2 === undefined) k2 = k;
|
17 | o[k2] = m[k];
|
18 | }));
|
19 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
20 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
21 | }) : function(o, v) {
|
22 | o["default"] = v;
|
23 | });
|
24 | var __importStar = (this && this.__importStar) || function (mod) {
|
25 | if (mod && mod.__esModule) return mod;
|
26 | var result = {};
|
27 | if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
28 | __setModuleDefault(result, mod);
|
29 | return result;
|
30 | };
|
31 | Object.defineProperty(exports, "__esModule", { value: true });
|
32 | exports.throwUnreachable = exports.wait = exports.runNpm = exports.fileKind = exports.isHttpUrl = void 0;
|
33 | const child_process_1 = require("child_process");
|
34 | const fsExtra = __importStar(require("fs-extra"));
|
35 | const url_1 = require("url");
|
36 | const util_1 = require("util");
|
37 |
|
38 | function isHttpUrl(str) {
|
39 | try {
|
40 | const url = new url_1.URL(str);
|
41 |
|
42 |
|
43 | return url.protocol === 'http:' || url.protocol === 'https:';
|
44 | }
|
45 | catch (e) {
|
46 | return false;
|
47 | }
|
48 | }
|
49 | exports.isHttpUrl = isHttpUrl;
|
50 | async function fileKind(path) {
|
51 | try {
|
52 | const stat = await fsExtra.stat(path);
|
53 | if (stat.isDirectory()) {
|
54 | return 'dir';
|
55 | }
|
56 | if (stat.isFile()) {
|
57 | return 'file';
|
58 | }
|
59 | }
|
60 | catch (e) {
|
61 | if (e.code === 'ENOENT') {
|
62 | return undefined;
|
63 | }
|
64 | throw e;
|
65 | }
|
66 | }
|
67 | exports.fileKind = fileKind;
|
68 | const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
69 | async function runNpm(args, options) {
|
70 | return util_1.promisify(child_process_1.execFile)(npmCmd, args, options).then(({ stdout }) => stdout);
|
71 | }
|
72 | exports.runNpm = runNpm;
|
73 |
|
74 |
|
75 |
|
76 | exports.wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
77 |
|
78 |
|
79 |
|
80 |
|
81 | function throwUnreachable(_unreachable, message) {
|
82 | throw new Error(message);
|
83 | }
|
84 | exports.throwUnreachable = throwUnreachable;
|
85 |
|
\ | No newline at end of file |