1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = require("fs");
const child_process_1 = require("child_process");
const util_1 = require("util");
const rimraf = require("rimraf");
const rimrafAsync = util_1.promisify(rimraf);
exports.rimrafAsync = rimrafAsync;
exports.STDIN_FLAG = '[stdin]';
function each(list, action) {
return __awaiter(this, void 0, void 0, function* () {
const l = yield list;
return Promise.all(l.map(action));
});
}
exports.each = each;
function wrap(code) {
return '!(function () {' + code + '})();';
}
exports.wrap = wrap;
function falseOnEnoent(e) {
if (e.code === 'ENOENT') {
return false;
}
throw e;
}
function padRight(str, l) {
return (str + ' '.repeat(l)).substr(0, l);
}
exports.padRight = padRight;
const bound = function bound(target, propertyKey, descriptor) {
const configurable = true;
return {
configurable,
get() {
const value = descriptor.value.bind(this);
Object.defineProperty(this, propertyKey, {
configurable,
value,
writable: true,
});
return value;
},
};
};
exports.bound = bound;
function dequote(input) {
input = input.trim();
const singleQuote = input.startsWith("'") && input.endsWith("'");
const doubleQuote = input.startsWith('"') && input.endsWith('"');
if (singleQuote || doubleQuote) {
return input.slice(1).slice(0, -1);
}
return input;
}
exports.dequote = dequote;
const readFileAsync = util_1.promisify(fs_1.readFile);
exports.readFileAsync = readFileAsync;
const writeFileAsync = util_1.promisify(fs_1.writeFile);
exports.writeFileAsync = writeFileAsync;
const statAsync = util_1.promisify(fs_1.stat);
exports.statAsync = statAsync;
const execFileAsync = util_1.promisify(child_process_1.execFile);
exports.execFileAsync = execFileAsync;
const isWindows = process.platform === 'win32';
exports.isWindows = isWindows;
function pathExistsAsync(path) {
return statAsync(path)
.then((x) => true)
.catch(falseOnEnoent);
}
exports.pathExistsAsync = pathExistsAsync;
function isDirectoryAsync(path) {
return statAsync(path)
.then((x) => x.isDirectory())
.catch(falseOnEnoent);
}
exports.isDirectoryAsync = isDirectoryAsync;
/**
* @param version See if this version is greather than the second one
* @param operand Version to compare against
*/
function semverGt(version, operand) {
const [cMajor, cMinor, cPatch] = version.split('.').map(Number);
let [major, minor, patch] = operand.split('.').map(Number);
if (!minor)
minor = 0;
if (!patch)
patch = 0;
return (cMajor > major ||
(cMajor === major && cMinor > minor) ||
(cMajor === major && cMinor === minor && cPatch > patch));
}
exports.semverGt = semverGt;
|