tasktui 1.0.8 → 1.0.22
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 +4 -4
- package/dist/tasks.d.ts +1 -1
- package/dist/tasks.js +18 -4
- package/package.json +1 -1
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', () => {
|
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
|
@@ -82,10 +82,24 @@ function checkQueue(state, onUpdate) {
|
|
|
82
82
|
}
|
|
83
83
|
state.queue = next;
|
|
84
84
|
}
|
|
85
|
-
export function cleanup(state) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
export async function cleanup(state) {
|
|
86
|
+
const processes = [...state.childProcesses.entries()].filter(([_, proc]) => !proc.killed);
|
|
87
|
+
if (processes.length === 0)
|
|
88
|
+
return;
|
|
89
|
+
const exitPromises = processes.map(([_, proc]) => new Promise((resolve) => {
|
|
90
|
+
proc.on('close', resolve);
|
|
91
|
+
proc.kill('SIGTERM');
|
|
92
|
+
}));
|
|
93
|
+
const timeout = new Promise((resolve) => setTimeout(() => resolve('timeout'), 5000));
|
|
94
|
+
const result = await Promise.race([
|
|
95
|
+
Promise.all(exitPromises).then(() => 'done'),
|
|
96
|
+
timeout,
|
|
97
|
+
]);
|
|
98
|
+
if (result === 'timeout') {
|
|
99
|
+
for (const [_, proc] of processes) {
|
|
100
|
+
if (!proc.killed) {
|
|
101
|
+
proc.kill('SIGKILL');
|
|
102
|
+
}
|
|
89
103
|
}
|
|
90
104
|
}
|
|
91
105
|
}
|