@hackwaly/task 0.3.3 → 0.3.5

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/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@hackwaly/task",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
- "repository": "github:hackwaly/task",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/hackwaly/task.git"
9
+ },
7
10
  "bin": {
8
11
  "task": "bin/task"
9
12
  },
package/src/config.js CHANGED
@@ -33,19 +33,28 @@ export function configInit(importMeta) {
33
33
  interruptible: config.interruptible ?? false,
34
34
  };
35
35
  const def = {
36
- run: config.run
37
- ? async (ctx) => {
38
- process.stdout.write(`▪▪▪▪ ${styles.bold.open}${meta.name}${styles.bold.close}\n`);
39
- await config.run(ctx);
40
- }
41
- : command !== undefined
42
- ? async (ctx) => {
43
- process.stdout.write(`▪▪▪▪ ${styles.bold.open}${meta.name}${styles.bold.close}\n`);
36
+ run: async (ctx) => {
37
+ process.stdout.write(`▪▪▪▪ ${styles.bold.open}${meta.name}${styles.bold.close}\n`);
38
+ try {
39
+ if (typeof config.run === "function") {
40
+ await config.run(ctx);
41
+ }
42
+ else if (command !== undefined) {
44
43
  await runCommand(command, meta, ctx);
45
44
  }
46
- : async () => {
47
- process.stdout.write(`▪▪▪▪ ${styles.bold.open}${meta.name}${styles.bold.close}\n`);
48
- },
45
+ else {
46
+ // No-op
47
+ }
48
+ }
49
+ catch (err) {
50
+ if (err instanceof DOMException && err.name === "AbortError") {
51
+ process.stdout.write(`✖✖✖✖ ${styles.bold.open}${meta.name} aborted${styles.bold.close}\n`);
52
+ }
53
+ else {
54
+ throw err;
55
+ }
56
+ }
57
+ },
49
58
  meta: meta,
50
59
  deps: new Set(),
51
60
  invDeps: new Set(),
package/src/scheduler.js CHANGED
@@ -26,7 +26,7 @@ export async function start(taskChan, options) {
26
26
  pendingSet.delete(task);
27
27
  readySet.add(task);
28
28
  readySignal.next();
29
- // Mark inverse dependencies as pending, so they won't become ready
29
+ // Mark inverse dependencies as pending
30
30
  for (const invDep of task.invDeps) {
31
31
  if (dirtySet.has(invDep)) {
32
32
  pendingSet.add(invDep);
@@ -40,7 +40,9 @@ export async function start(taskChan, options) {
40
40
  const { promise, aborter } = runningSet.get(task);
41
41
  runningSet.delete(task);
42
42
  abortedRunningSet.set(task, promise);
43
- aborter.abort();
43
+ if (!aborter.signal.aborted) {
44
+ aborter.abort();
45
+ }
44
46
  };
45
47
  const addDirtyAndCheckReady = (task) => {
46
48
  if (runningSet.has(task)) {
@@ -64,7 +66,9 @@ export async function start(taskChan, options) {
64
66
  const runTask = async (task, abort) => {
65
67
  if (runningSet.has(task)) {
66
68
  const { promise, aborter } = runningSet.get(task);
67
- aborter.abort();
69
+ if (!aborter.signal.aborted) {
70
+ aborter.abort();
71
+ }
68
72
  await Promise.allSettled([promise]);
69
73
  }
70
74
  await task.run({ abort });