Download chakra-ui/packages/cli/src/utils/tasks.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 602 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/chakra-ui/packages/cli/src/utils/tasks.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@f5071caa249115f3b590492f1c8eb471e02aae4b/chakra-ui/packages/cli/src/utils/tasks.ts
-
curl -L -o tasks.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/chakra-ui/packages/cli/src/utils/tasks.ts
602 Bytes
| import { spinner } from "@clack/prompts" | |
| type MaybePromise<T> = T | Promise<T> | |
| type MessageFn = (message: string) => void | |
| interface Task { | |
| title: string | |
| task: (message: MessageFn) => MaybePromise<string | void> | |
| enabled?: boolean | |
| } | |
| export const tasks = async (tasks: Task[]) => { | |
| for (const task of tasks) { | |
| if (task.enabled === false) continue | |
| const s = spinner() | |
| s.start(task.title) | |
| try { | |
| const result = await task.task(s.message) | |
| s.stop(result || task.title) | |
| } catch (error) { | |
| s.stop(`${task.title}\n` + String(error)) | |
| throw error | |
| } | |
| } | |
| } | |