tasktui 1.0.8 → 1.0.23

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/app.js CHANGED
@@ -17,13 +17,13 @@ function handleMove(steps) {
17
17
  render(state);
18
18
  }
19
19
  }
20
- function loadAndProcessConfig(configPath) {
20
+ async function loadAndProcessConfig(configPath) {
21
21
  try {
22
22
  const config = loadConfig(configPath);
23
23
  state.config = config;
24
24
  const tasks = config?.tasks ?? {};
25
25
  if (!Object.keys(tasks).length && state.init) {
26
- cleanup(state);
26
+ await cleanup(state);
27
27
  process.exit(0);
28
28
  }
29
29
  state.init = true;
@@ -60,8 +60,8 @@ ui.screen.key(['up', 'k'], () => {
60
60
  ui.screen.key(['down', 'j'], () => {
61
61
  handleMove(1);
62
62
  });
63
- ui.screen.key(['C-c', 'q'], () => {
64
- cleanup(state);
63
+ ui.screen.key(['C-c', 'q'], async () => {
64
+ await cleanup(state);
65
65
  process.exit(0);
66
66
  });
67
67
  ui.screen.key('m', () => {
@@ -1,3 +1,4 @@
1
1
  declare const CONFIG_PATH = "./tasktui.config.json";
2
2
  declare const KEYBINDS: string[];
3
- export { CONFIG_PATH, KEYBINDS };
3
+ declare const CLEANUP_TIMEOUT = 10000;
4
+ export { CLEANUP_TIMEOUT, CONFIG_PATH, KEYBINDS };
package/dist/constants.js CHANGED
@@ -5,4 +5,5 @@ const KEYBINDS = [
5
5
  '↓ or j - Select next task',
6
6
  'Ctrl-c or q - Quit',
7
7
  ];
8
- export { CONFIG_PATH, KEYBINDS };
8
+ const CLEANUP_TIMEOUT = 10000;
9
+ export { CLEANUP_TIMEOUT, CONFIG_PATH, KEYBINDS };
package/dist/tasks.d.ts CHANGED
@@ -2,4 +2,4 @@ import { AppState } from './state.js';
2
2
  import { Task } from './types.js';
3
3
  export declare function ensureDependencies(task: string, deps: string[], state: AppState): boolean;
4
4
  export declare function spawnTask(name: string, task: Task, state: AppState, onUpdate: () => void): void;
5
- export declare function cleanup(state: AppState): void;
5
+ export declare function cleanup(state: AppState): Promise<void>;
package/dist/tasks.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import childProcess from 'node:child_process';
2
+ import { CLEANUP_TIMEOUT } from './constants.js';
2
3
  import { showError } from './renderer.js';
3
4
  import { ensureError } from './utils.js';
4
5
  export function ensureDependencies(task, deps, state) {
@@ -82,10 +83,24 @@ function checkQueue(state, onUpdate) {
82
83
  }
83
84
  state.queue = next;
84
85
  }
85
- export function cleanup(state) {
86
- for (const [_, proc] of state.childProcesses.entries()) {
87
- if (!proc.killed) {
88
- proc.kill('SIGTERM');
86
+ export async function cleanup(state) {
87
+ const processes = [...state.childProcesses.entries()].filter(([_, proc]) => !proc.killed);
88
+ if (processes.length === 0)
89
+ return;
90
+ const exitPromises = processes.map(([_, proc]) => new Promise((resolve) => {
91
+ proc.on('close', resolve);
92
+ proc.kill('SIGTERM');
93
+ }));
94
+ const timeout = new Promise((resolve) => setTimeout(() => resolve('timeout'), CLEANUP_TIMEOUT));
95
+ const result = await Promise.race([
96
+ Promise.all(exitPromises).then(() => 'done'),
97
+ timeout,
98
+ ]);
99
+ if (result === 'timeout') {
100
+ for (const [_, proc] of processes) {
101
+ if (!proc.killed) {
102
+ proc.kill('SIGKILL');
103
+ }
89
104
  }
90
105
  }
91
106
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tasktui",
3
3
  "description": "Run tasks in a multiplexed terminal with dependency management.",
4
- "version": "1.0.8",
4
+ "version": "1.0.23",
5
5
  "license": "MIT",
6
6
  "bin": "dist/cli.js",
7
7
  "type": "module",