Skip to content

Commit 0bcc3d7

Browse files
Merge pull request #3 from privatenumber/develop
2 parents 9330bb1 + 541d7b2 commit 0bcc3d7

File tree

6 files changed

+21
-21
lines changed

6 files changed

+21
-21
lines changed

.github/tasuku.png

-52.4 KB
Binary file not shown.

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ jobs:
2626
run: npm run test --if-present
2727
- name: Release
2828
env:
29-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
3030
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
3131
run: npx semantic-release

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<p align="center">
33
<img src=".github/tasuku.svg">
44
<br>
5-
<i>The minimal task runner</i>
5+
<i>The minimal task runner for Node.js</i>
66
</p>
77

88
### Features
@@ -11,6 +11,8 @@
1111
- Unopinionated
1212
- Type-safe
1313

14+
[Try it out online](https://stackblitz.com/edit/tasuku-demo?file=index.js)
15+
1416
<sub>Support this project by starring and sharing it. [Follow me](https://github.com/privatenumber) to see what other cool projects I'm working on.</sub>
1517

1618
## Install

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"scripts": {
2525
"lint": "eslint .",
2626
"test": "jest",
27-
"typecheck": "tsc --noEmit",
27+
"typecheck": "tsc --noEmit && :",
2828
"build": "rm -rf dist && tsup src/index.ts --dts --minify --no-splitting --external 'yoga-layout-prebuilt'"
2929
},
3030
"husky": {
@@ -44,7 +44,6 @@
4444
"@types/jest": "^26.0.23",
4545
"@types/node": "^15.6.1",
4646
"@types/react": "^17.0.4",
47-
"dts": "^0.1.1",
4847
"es-jest": "^1.2.0",
4948
"eslint": "^7.24.0",
5049
"esno": "^0.5.0",

pnpm-lock.yaml

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,30 +36,35 @@ const createTaskInnerApi = (taskState: TaskObject) => {
3636
return api;
3737
};
3838

39-
type TaskFunction = (taskHelpers: ReturnType<typeof createTaskInnerApi>) => Promise<unknown>;
39+
// Until full ESM
40+
// eslint-disable-next-line @typescript-eslint/no-namespace
41+
namespace task {
42+
export type TaskInnerApi = ReturnType<typeof createTaskInnerApi>;
43+
export type TaskFunction = (taskHelpers: TaskInnerApi) => Promise<unknown>;
44+
}
4045

41-
type TaskAPI<T extends TaskFunction> = {
46+
type TaskApi<T extends task.TaskFunction> = {
4247
run: () => Promise<Awaited<ReturnType<T>>>;
4348
clear: () => void;
4449
};
4550
type TaskResults<
46-
T extends TaskFunction,
47-
Tasks extends TaskAPI<T>[]
51+
T extends task.TaskFunction,
52+
Tasks extends TaskApi<T>[]
4853
> = {
4954
[key in keyof Tasks]: (
50-
Tasks[key] extends TaskAPI<T>
55+
Tasks[key] extends TaskApi<T>
5156
? Awaited<ReturnType<Tasks[key]['run']>>
5257
: Tasks[key]
5358
);
5459
};
5560

5661
let app: ReturnType<typeof createApp>;
5762

58-
function registerTask<T extends TaskFunction>(
63+
function registerTask<T extends task.TaskFunction>(
5964
taskList: TaskList,
6065
taskTitle: string,
6166
taskFunction: T,
62-
): TaskAPI<T> {
67+
): TaskApi<T> {
6368
if (!app) {
6469
app = createApp(taskList);
6570
taskList.isRoot = true;
@@ -105,7 +110,7 @@ function registerTask<T extends TaskFunction>(
105110
function createTaskFunction(
106111
taskList: TaskList,
107112
) {
108-
async function task<T extends TaskFunction>(
113+
async function task<T extends task.TaskFunction>(
109114
title: string,
110115
taskFunction: T,
111116
) {
@@ -118,7 +123,7 @@ function createTaskFunction(
118123
);
119124
}
120125

121-
const createTask = <T extends TaskFunction>(
126+
const createTask = <T extends task.TaskFunction>(
122127
title: string,
123128
taskFunction: T,
124129
) => registerTask(
@@ -128,8 +133,8 @@ function createTaskFunction(
128133
);
129134

130135
task.group = async <
131-
T extends TaskFunction,
132-
Tasks extends TaskAPI<T>[]
136+
T extends task.TaskFunction,
137+
Tasks extends TaskApi<T>[]
133138
>(
134139
createTasks: (taskCreator: typeof createTask) => readonly [...Tasks],
135140
options?: Options,

0 commit comments

Comments
 (0)