Skip to content

Commit c6c6305

Browse files
authored
Merge pull request #3 from lambdalisue/support-node
Support Node
2 parents bb05a44 + ebb088c commit c6c6305

File tree

10 files changed

+2201
-8
lines changed

10 files changed

+2201
-8
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
with:
2323
deno-version: ${{ env.DENO_VERSION }}
2424
- name: Lint
25-
run: deno lint
25+
run: make lint
2626

2727
format:
2828
runs-on: ubuntu-latest
@@ -32,8 +32,7 @@ jobs:
3232
with:
3333
deno-version: ${{ env.DENO_VERSION }}
3434
- name: Format
35-
run: |
36-
deno fmt --check
35+
run: make fmt-check
3736

3837
test:
3938
runs-on: ubuntu-latest
@@ -43,8 +42,7 @@ jobs:
4342
with:
4443
deno-version: ${{ env.DENO_VERSION }}
4544
- name: Test
46-
run: |
47-
deno test
45+
run: make test
4846
timeout-minutes: 5
4947

5048
typecheck:
@@ -55,5 +53,4 @@ jobs:
5553
with:
5654
deno-version: ${{ env.DENO_VERSION }}
5755
- name: Type check
58-
run: |
59-
deno test --unstable --no-run ./*.ts
56+
run: make type-check

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.tools
2+
/node_modules

.node/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/dist

.node/node.t.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// https://github.com/microsoft/TypeScript/issues/3926
2+
interface ErrorConstructor {
3+
captureStackTrace(thisArg: any, func: any): void;
4+
}

.node/tsconfig.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"files": ["./node.t.ts"],
3+
"include": ["../**/*.ts"],
4+
"exclude": [".", "../**/*_test.ts"],
5+
"compilerOptions": {
6+
"allowSyntheticDefaultImports": true,
7+
"declaration": true,
8+
"declarationMap": true,
9+
"module": "commonjs",
10+
"moduleResolution": "node",
11+
"noEmitOnError": true,
12+
"outDir": "./dist",
13+
"target": "ES2019"
14+
}
15+
}

Makefile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
TOOLS := ${CURDIR}/.tools
2+
TARGETS := $$(find . \( -name '*.ts' -or -name '*.md' \) -not -path './.node/*' -not -path './node_modules/*')
3+
4+
.DEFAULT_GOAL := help
5+
6+
help:
7+
@cat $(MAKEFILE_LIST) | \
8+
perl -ne 'print if /^\w+.*##/;' | \
9+
perl -pe 's/(.*):.*##\s*/sprintf("%-20s",$$1)/eg;'
10+
11+
tools: FORCE ## Install development tools
12+
@mkdir -p ${TOOLS}
13+
@deno install -A -f -n udd --root ${TOOLS} https://deno.land/x/[email protected]/main.ts
14+
15+
fmt: FORCE ## Format code
16+
@deno fmt ${TARGETS}
17+
18+
fmt-check: FORCE ## Format check
19+
@deno fmt --check ${TARGETS}
20+
21+
lint: FORCE ## Lint code
22+
@deno lint ${TARGETS}
23+
24+
type-check: FORCE ## Type check
25+
@deno test --unstable --no-run ${TARGETS}
26+
27+
test: FORCE ## Test
28+
@deno test --unstable -A ${TARGETS}
29+
30+
update: FORCE ## Update dependencies
31+
@${TOOLS}/bin/udd ${TARGETS}
32+
@make fmt
33+
34+
FORCE:

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# unknownutil
22

3+
[![npm](http://img.shields.io/badge/available%20on-npm-lightgrey.svg?logo=npm&logoColor=white)](https://www.npmjs.com/package/unknownutil)
34
[![deno land](http://img.shields.io/badge/available%20on-deno.land/x-lightgrey.svg?logo=deno)](https://deno.land/x/unknownutil)
45
[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/unknownutil/mod.ts)
56
[![Test](https://github.com/lambdalisue/deno-unknownutil/workflows/Test/badge.svg)](https://github.com/lambdalisue/deno-unknownutil/actions?query=workflow%3ATest)
7+
[![npm version](https://badge.fury.io/js/unknownutil.svg)](https://badge.fury.io/js/unknownutil)
68

79
A utility pack for handling `unknown` type.
810

@@ -143,6 +145,40 @@ ensureLike({}, b); // Now 'b' is 'Record<string, unknown>'
143145
ensureLike({ foo: "", bar: 0 }, b); // Now 'b' is '{foo: string, bar: number}'
144146
```
145147

148+
## Development
149+
150+
Lint code like:
151+
152+
```text
153+
make lint
154+
```
155+
156+
Format code like
157+
158+
```text
159+
make fmt
160+
```
161+
162+
Check types like
163+
164+
```text
165+
make type-check
166+
```
167+
168+
Run tests like:
169+
170+
```text
171+
make test
172+
```
173+
174+
Publish new version with:
175+
176+
```
177+
npm version {major/minor/patch}
178+
npm publish
179+
git push --tags
180+
```
181+
146182
## License
147183

148184
The code follows MIT license written in [LICENSE](./LICENSE). Contributors need

deps_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from "https://deno.land/std@0.93.0/testing/asserts.ts";
1+
export * from "https://deno.land/std@0.106.0/testing/asserts.ts";

0 commit comments

Comments
 (0)