Skip to content

Commit

Permalink
Merge pull request #3 from lambdalisue/fix-deno-ladn
Browse files Browse the repository at this point in the history
🐛 Fix for deno.land
  • Loading branch information
lambdalisue authored May 14, 2024
2 parents 8d22e9a + 9d4070d commit 910df8a
Show file tree
Hide file tree
Showing 13 changed files with 100 additions and 28 deletions.
30 changes: 24 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ env:
NODE_VERSION: 16.x

on:
schedule:
- cron: "0 7 * * 0"
push:
branches:
- main
pull_request:
paths:
- "**.md"
- "**.ts"
- "deno.jsonc"
- ".github/workflows/test.yml"
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -38,11 +41,15 @@ jobs:
deno-version: ${{ env.DENO_VERSION }}
- name: Test
run: |
deno task test
deno task test:coverage
timeout-minutes: 5
- name: JSR publish (dry-run)
run: |
deno publish --dry-run
- run: |
deno task coverage --lcov > coverage.lcov
- uses: codecov/codecov-action@v4
with:
os: ${{ runner.os }}
files: ./coverage.lcov
token: ${{ secrets.CODECOV_TOKEN }}

build-npm:
runs-on: ubuntu-latest
Expand All @@ -57,3 +64,14 @@ jobs:
registry-url: "https://registry.npmjs.org"
- name: Build
run: deno task build-npm

jsr-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
with:
deno-version: ${{ env.DENO_VERSION }}
- name: Publish (dry-run)
run: |
deno publish --dry-run
48 changes: 48 additions & 0 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: update

on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

jobs:
update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
with:
deno-version: 1.x
- name: Configure Git
run: |
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
- name: Update dependencies and commit changes
run: deno task -q update:commit --summary ../title.txt --report ../body.md
- name: Check result
id: result
uses: andstor/file-existence-action@v2
with:
files: ../title.txt, ../body.md
- name: Read title.txt
id: title
if: steps.result.outputs.files_exists == 'true'
uses: juliangruber/read-file-action@v1
with:
path: ../title.txt
- name: Read body.md
id: body
if: steps.result.outputs.files_exists == 'true'
uses: juliangruber/read-file-action@v1
with:
path: ../body.md
- name: Create a pull request
if: steps.result.outputs.files_exists == 'true'
uses: peter-evans/create-pull-request@v6
with:
author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
branch: automation/update-dependencies
title: ${{ steps.title.outputs.content }}
body: ${{ steps.body.outputs.content }}
labels: automation
delete-branch: true
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# errorutil

[![jsr](https://img.shields.io/jsr/v/%40lambdalisue/errorutil?logo=javascript&logoColor=white)](https://jsr.io/@lambdalisue/errorutil)
[![denoland](https://img.shields.io/github/v/release/lambdalisue/deno-errorutil?logo=deno&label=denoland)](https://github.com/lambdalisue/deno-errorutil/releases)
[![JSR](https://jsr.io/badges/@lambdalisue/errorutil)](https://jsr.io/@lambdalisue/errorutil)
[![denoland](https://img.shields.io/github/v/release/lambdalisue/deno-errorutil?logo=deno&label=denoland)](https://deno.land/x/errorutil)
[![npm](http://img.shields.io/badge/available%20on-npm-lightgrey.svg?logo=npm&logoColor=white)](https://www.npmjs.com/package/@lambdalisue/errorutil)
[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/errorutil/mod.ts)
[![Test](https://github.com/lambdalisue/deno-errorutil/workflows/Test/badge.svg)](https://github.com/lambdalisue/deno-errorutil/actions?query=workflow%3ATest)
[![npm version](https://badge.fury.io/js/@lambdalisue%2Ferrorutil.svg)](https://badge.fury.io/js/@lambdalisue%2Ferrorutil)
[![codecov](https://codecov.io/gh/lambdalisue/deno-errorutil/graph/badge.svg?token=O0cA5Xj5la)](https://codecov.io/gh/lambdalisue/deno-errorutil)

A utility pack for handling error.

Expand Down
17 changes: 11 additions & 6 deletions deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@
"name": "@lambdalisue/errorutil",
"version": "0.0.0",
"exports": "./mod.ts",
"exclude": [
".coverage",
"npm"
],
"tasks": {
"build-npm": "deno run -A scripts/build_npm.ts $(git describe --tags --always --dirty)",
"check": "deno check ./**/*.ts",
"test": "deno test -A --parallel --shuffle --doc --coverage=.coverage",
"coverage": "deno coverage .coverage"
"check": "deno check **/*.ts",
"test": "deno test -A --doc --parallel --shuffle",
"test:coverage": "deno task test --coverage=.coverage",
"coverage": "deno coverage .coverage",
"update": "deno run --allow-env --allow-read --allow-write=. --allow-run=git,deno --allow-net=jsr.io,registry.npmjs.org jsr:@molt/cli ./*.ts",
"update:commit": "deno task -q update --commit --pre-commit=fmt,lint"
},
"imports": {
"@core/unknownutil": "jsr:@core/unknownutil@^3.17.2",
"@deno/dnt": "jsr:@deno/dnt@^0.41.1",
"@std/assert": "jsr:@std/assert@^0.221.0"
"https://deno.land/x/errorutil@$MODULE_VERSION/": "./"
}
}
4 changes: 2 additions & 2 deletions error_object.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { is, type Predicate } from "@core/unknownutil";
import { is } from "jsr:@core/unknownutil";

export type ErrorObject = {
proto: string;
Expand All @@ -8,7 +8,7 @@ export type ErrorObject = {
attributes: Record<string, unknown>;
};

export const isErrorObject: Predicate<ErrorObject> = is.ObjectOf({
export const isErrorObject: (x: unknown) => x is ErrorObject = is.ObjectOf({
proto: is.String,
name: is.String,
message: is.String,
Expand Down
2 changes: 1 addition & 1 deletion error_object_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals, assertInstanceOf } from "@std/assert";
import { assertEquals, assertInstanceOf } from "jsr:@std/assert";
import { fromErrorObject, toErrorObject } from "./error_object.ts";

class CustomError extends Error {
Expand Down
2 changes: 1 addition & 1 deletion raise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This is function thus can be used as an expression.
*
* ```typescript
* import { raise } from "./raise.ts";
* import { raise } from "https://deno.land/x/errorutil@$MODULE_VERSION/raise.ts";
*
* const fn = () => raise(new Error("fail"));
* ```
Expand Down
2 changes: 1 addition & 1 deletion raise_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertThrows } from "@std/assert";
import { assertThrows } from "jsr:@std/assert";
import { raise } from "./raise.ts";

Deno.test("raise", () => {
Expand Down
2 changes: 1 addition & 1 deletion scripts/build_npm.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { build, emptyDir } from "@deno/dnt";
import { build, emptyDir } from "jsr:@deno/dnt";

const name = "@lambdalisue/errorutil";
const version = Deno.args[0];
Expand Down
8 changes: 4 additions & 4 deletions try_or.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* Try to execute a function and return the result or a default value.
*
* ```ts
* import { tryOr } from "./try_or.ts";
* import { raise } from "./raise.ts";
* import { tryOr } from "https://deno.land/x/errorutil@$MODULE_VERSION/try_or.ts";
* import { raise } from "https://deno.land/x/errorutil@$MODULE_VERSION/raise.ts";
*
* // Sync
* console.log(tryOr(() => 1, 2)); // 1
Expand All @@ -30,8 +30,8 @@ export function tryOr<T>(
* Try to execute a function and return the result or execute another function.
*
* ```ts
* import { tryOrElse } from "./try_or.ts";
* import { raise } from "./raise.ts";
* import { tryOrElse } from "https://deno.land/x/errorutil@$MODULE_VERSION/try_or.ts";
* import { raise } from "https://deno.land/x/errorutil@$MODULE_VERSION/raise.ts";
*
* // Sync
* console.log(tryOrElse(() => 1, () => 2)); // 1
Expand Down
2 changes: 1 addition & 1 deletion try_or_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals, assertRejects, assertThrows } from "@std/assert";
import { assertEquals, assertRejects, assertThrows } from "jsr:@std/assert";
import { raise } from "./raise.ts";
import { tryOr, tryOrElse } from "./try_or.ts";

Expand Down
2 changes: 1 addition & 1 deletion unimplemented.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class UnimplementedError extends Error {
* For example, defining a mock object with `unimplemented` function should look like this:
*
* ```ts
* import { unimplemented } from "./unimplemented.ts";
* import { unimplemented } from "https://deno.land/x/errorutil@$MODULE_VERSION/unimplemented.ts";
*
* type Service = {
* get(id: string): Promise<string>;
Expand Down
4 changes: 2 additions & 2 deletions unreachable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class UnreachableError extends Error {
* For example, the following code passed type checking.
*
* ```ts
* import { unreachable } from "./unreachable.ts";
* import { unreachable } from "https://deno.land/x/errorutil@$MODULE_VERSION/unreachable.ts";
*
* type Animal = "dog" | "cat";
*
Expand All @@ -41,7 +41,7 @@ export class UnreachableError extends Error {
* But the following code because a case for "bird" is missing.
*
* ```ts
* import { unreachable } from "./unreachable.ts";
* import { unreachable } from "https://deno.land/x/errorutil@$MODULE_VERSION/unreachable.ts";
*
* type Animal = "dog" | "cat" | "bird";
*
Expand Down

0 comments on commit 910df8a

Please sign in to comment.