zarro 1.183.7 → 1.185.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/gulp-tasks/modules/parse-flag.js +47 -0
- package/package.json +1 -1
- package/types.d.ts +4 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(function () {
|
|
3
|
+
const positives = new Set([
|
|
4
|
+
"yes",
|
|
5
|
+
"y",
|
|
6
|
+
"1",
|
|
7
|
+
"true",
|
|
8
|
+
"on"
|
|
9
|
+
]);
|
|
10
|
+
const negatives = new Set([
|
|
11
|
+
"no",
|
|
12
|
+
"n",
|
|
13
|
+
"0",
|
|
14
|
+
"false",
|
|
15
|
+
"off"
|
|
16
|
+
]);
|
|
17
|
+
function parseFlag(value, fallback) {
|
|
18
|
+
const lower = (value || "").toLowerCase();
|
|
19
|
+
if (positives.has(lower)) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
if (negatives.has(lower)) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
if (fallback !== undefined) {
|
|
26
|
+
return fallback;
|
|
27
|
+
}
|
|
28
|
+
const possiblePositives = [];
|
|
29
|
+
for (const item of positives) {
|
|
30
|
+
possiblePositives.push(item);
|
|
31
|
+
}
|
|
32
|
+
const possibleNegatives = [];
|
|
33
|
+
for (const item of negatives) {
|
|
34
|
+
possibleNegatives.push(item);
|
|
35
|
+
}
|
|
36
|
+
throw new Error(`${value} is not a valid flag value.
|
|
37
|
+
Try one of:
|
|
38
|
+
- accepted truthy values:
|
|
39
|
+
${possiblePositives.join(", ")}
|
|
40
|
+
- accepted falsey values:
|
|
41
|
+
${possibleNegatives.join(", ")}
|
|
42
|
+
`);
|
|
43
|
+
}
|
|
44
|
+
module.exports = {
|
|
45
|
+
parseFlag
|
|
46
|
+
};
|
|
47
|
+
})();
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -546,6 +546,10 @@ declare global {
|
|
|
546
546
|
open(url: string): Promise<void>;
|
|
547
547
|
}
|
|
548
548
|
|
|
549
|
+
interface ParseFlag {
|
|
550
|
+
parseFlag: (value: string, fallback?: boolean) => boolean;
|
|
551
|
+
}
|
|
552
|
+
|
|
549
553
|
type ResolveNugetApiKey = (forSource?: string) => Promise<Optional<string>>;
|
|
550
554
|
|
|
551
555
|
interface Env
|