Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
with:
deno-version: ${{ env.DENO_VERSION }}
- name: Lint
run: deno lint
run: make lint

format:
runs-on: ubuntu-latest
Expand All @@ -32,8 +32,7 @@ jobs:
with:
deno-version: ${{ env.DENO_VERSION }}
- name: Format
run: |
deno fmt --check
run: make fmt-check

test:
runs-on: ubuntu-latest
Expand All @@ -43,8 +42,7 @@ jobs:
with:
deno-version: ${{ env.DENO_VERSION }}
- name: Test
run: |
deno test
run: make test
timeout-minutes: 5

typecheck:
Expand All @@ -55,5 +53,4 @@ jobs:
with:
deno-version: ${{ env.DENO_VERSION }}
- name: Type check
run: |
deno test --unstable --no-run ./*.ts
run: make type-check
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.tools
/node_modules
1 change: 1 addition & 0 deletions .node/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/dist
4 changes: 4 additions & 0 deletions .node/node.t.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// https://github.com/microsoft/TypeScript/issues/3926
interface ErrorConstructor {
captureStackTrace(thisArg: any, func: any): void;
}
15 changes: 15 additions & 0 deletions .node/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"files": ["./node.t.ts"],
"include": ["../**/*.ts"],
"exclude": [".", "../**/*_test.ts"],
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"declaration": true,
"declarationMap": true,
"module": "commonjs",
"moduleResolution": "node",
"noEmitOnError": true,
"outDir": "./dist",
"target": "ES2019"
}
}
34 changes: 34 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
TOOLS := ${CURDIR}/.tools
TARGETS := $$(find . \( -name '*.ts' -or -name '*.md' \) -not -path './.node/*' -not -path './node_modules/*')

.DEFAULT_GOAL := help

help:
@cat $(MAKEFILE_LIST) | \
perl -ne 'print if /^\w+.*##/;' | \
perl -pe 's/(.*):.*##\s*/sprintf("%-20s",$$1)/eg;'

tools: FORCE ## Install development tools
@mkdir -p ${TOOLS}
@deno install -A -f -n udd --root ${TOOLS} https://deno.land/x/udd@0.5.0/main.ts

fmt: FORCE ## Format code
@deno fmt ${TARGETS}

fmt-check: FORCE ## Format check
@deno fmt --check ${TARGETS}

lint: FORCE ## Lint code
@deno lint ${TARGETS}

type-check: FORCE ## Type check
@deno test --unstable --no-run ${TARGETS}

test: FORCE ## Test
@deno test --unstable -A ${TARGETS}

update: FORCE ## Update dependencies
@${TOOLS}/bin/udd ${TARGETS}
@make fmt

FORCE:
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# unknownutil

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

A utility pack for handling `unknown` type.

Expand Down Expand Up @@ -141,6 +143,40 @@ ensureLike({}, b); // Now 'b' is 'Record<string, unknown>'
ensureLike({ foo: "", bar: 0 }, b); // Now 'b' is '{foo: string, bar: number}'
```

## Development

Lint code like:

```text
make lint
```

Format code like

```text
make fmt
```

Check types like

```text
make type-check
```

Run tests like:

```text
make test
```

Publish new version with:

```
npm version {major/minor/patch}
npm publish
git push --tags
```

## License

The code follows MIT license written in [LICENSE](./LICENSE). Contributors need
Expand Down
2 changes: 1 addition & 1 deletion deps_test.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "https://deno.land/std@0.93.0/testing/asserts.ts";
export * from "https://deno.land/std@0.106.0/testing/asserts.ts";
Loading