hereby 1.1.0 → 1.2.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/dist/cli/index.js +5 -1
- package/dist/cli/parseArgs.js +7 -0
- package/dist/cli/runner.js +2 -1
- package/dist/cli/utils.js +6 -0
- package/package.json +2 -2
package/dist/cli/index.js
CHANGED
|
@@ -35,6 +35,10 @@ async function mainWorker(d) {
|
|
|
35
35
|
if (await reexec(d, herebyfilePath)) {
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
|
+
if (args.version) {
|
|
39
|
+
d.log(`hereby ${d.version}`);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
38
42
|
d.chdir(path.dirname(herebyfilePath));
|
|
39
43
|
d.log(`Using ${simplifyPath(herebyfilePath)}`);
|
|
40
44
|
const herebyfile = await loadHerebyfile(herebyfilePath);
|
|
@@ -66,7 +70,7 @@ export function selectTasks(herebyfile, taskNames) {
|
|
|
66
70
|
let message = `Task "${name}" does not exist or is not exported in the Herebyfile.`;
|
|
67
71
|
const candidate = closest(name, Array.from(allTasks.keys()));
|
|
68
72
|
if (distance(name, candidate) < name.length * 0.4) {
|
|
69
|
-
message += ` Did you mean "${candidate}
|
|
73
|
+
message += ` Did you mean "${candidate}"?`;
|
|
70
74
|
}
|
|
71
75
|
throw new UserError(message);
|
|
72
76
|
}
|
package/dist/cli/parseArgs.js
CHANGED
|
@@ -10,6 +10,7 @@ export function parseArgs(argv) {
|
|
|
10
10
|
{ name: "herebyfile", type: String },
|
|
11
11
|
{ name: "tasks", alias: "T", type: Boolean },
|
|
12
12
|
{ name: "help", alias: "h", type: Boolean },
|
|
13
|
+
{ name: "version", type: Boolean },
|
|
13
14
|
], {
|
|
14
15
|
argv,
|
|
15
16
|
stopAtFirstUnknown: true,
|
|
@@ -19,6 +20,7 @@ export function parseArgs(argv) {
|
|
|
19
20
|
run: options["run"],
|
|
20
21
|
herebyfile: options["herebyfile"],
|
|
21
22
|
printTasks: options["tasks"],
|
|
23
|
+
version: options["version"],
|
|
22
24
|
};
|
|
23
25
|
}
|
|
24
26
|
export function getUsage() {
|
|
@@ -53,6 +55,11 @@ export function getUsage() {
|
|
|
53
55
|
alias: "T",
|
|
54
56
|
type: Boolean,
|
|
55
57
|
},
|
|
58
|
+
{
|
|
59
|
+
name: "version",
|
|
60
|
+
description: "Print the current hereby version.",
|
|
61
|
+
type: Boolean,
|
|
62
|
+
},
|
|
56
63
|
],
|
|
57
64
|
},
|
|
58
65
|
{
|
package/dist/cli/runner.js
CHANGED
|
@@ -59,7 +59,8 @@ export class Runner {
|
|
|
59
59
|
return; // Skip logging.
|
|
60
60
|
}
|
|
61
61
|
this._errored = true;
|
|
62
|
-
|
|
62
|
+
const took = Date.now() - checkDefined(this._startTimes.get(task));
|
|
63
|
+
this._d.error(`Error in ${chalk.red(task.options.name)} in ${this._d.prettyMilliseconds(took)}\n${e}`);
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
function checkDefined(value) {
|
package/dist/cli/utils.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import fs from "fs/promises";
|
|
1
2
|
import os from "os";
|
|
2
3
|
import path from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
3
5
|
export function taskSorter(a, b) {
|
|
4
6
|
return stringSorter(a.options.name, b.options.name);
|
|
5
7
|
}
|
|
@@ -40,6 +42,9 @@ export async function real() {
|
|
|
40
42
|
const { default: foregroundChild } = await import("foreground-child");
|
|
41
43
|
const { resolve } = await import("import-meta-resolve");
|
|
42
44
|
const { default: prettyMilliseconds } = await import("pretty-ms");
|
|
45
|
+
const packageJsonPath = fileURLToPath(await resolve("hereby/package.json", import.meta.url));
|
|
46
|
+
const packageJson = await fs.readFile(packageJsonPath, "utf-8");
|
|
47
|
+
const { version } = JSON.parse(packageJson);
|
|
43
48
|
/* eslint-disable no-restricted-globals */
|
|
44
49
|
return {
|
|
45
50
|
log: console.log,
|
|
@@ -55,6 +60,7 @@ export async function real() {
|
|
|
55
60
|
process.exitCode = code;
|
|
56
61
|
},
|
|
57
62
|
numCPUs: os.cpus().length,
|
|
63
|
+
version,
|
|
58
64
|
foregroundChild,
|
|
59
65
|
resolve,
|
|
60
66
|
prettyMilliseconds,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hereby",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "A simple task runner",
|
|
5
5
|
"repository": "github:jakebailey/hereby",
|
|
6
6
|
"type": "module",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"tagName": "v${version}"
|
|
108
108
|
},
|
|
109
109
|
"hooks": {
|
|
110
|
-
"before:init": "npm run test"
|
|
110
|
+
"before:init": "npm run build && npm run test"
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
}
|