Skip to content

Commit

Permalink
Merge pull request #1 from lambdalisue/support-jsr
Browse files Browse the repository at this point in the history
Support jsr
  • Loading branch information
lambdalisue committed Apr 6, 2024
2 parents c810cbe + 86f666a commit 8d22e9a
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 73 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/jsr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: jsr

env:
DENO_VERSION: 1.x

on:
push:
tags:
- "v*"

permissions:
contents: read
id-token: write

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: denoland/setup-deno@v1
with:
deno-version: ${{ env.DENO_VERSION }}
- name: Publish
run: |
deno run -A jsr:@david/publish-on-tag@0.1.3
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
check:
Expand Down Expand Up @@ -39,6 +40,9 @@ jobs:
run: |
deno task test
timeout-minutes: 5
- name: JSR publish (dry-run)
run: |
deno publish --dry-run
build-npm:
runs-on: ubuntu-latest
Expand Down
49 changes: 0 additions & 49 deletions .github/workflows/update.yml

This file was deleted.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# 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)
[![npm](http://img.shields.io/badge/available%20on-npm-lightgrey.svg?logo=npm&logoColor=white)](https://www.npmjs.com/package/@lambdalisue/errorutil)
[![deno land](http://img.shields.io/badge/available%20on-deno.land/x-lightgrey.svg?logo=deno)](https://deno.land/x/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)
Expand Down
15 changes: 10 additions & 5 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
{
"lock": false,
"name": "@lambdalisue/errorutil",
"version": "0.0.0",
"exports": "./mod.ts",
"tasks": {
"build-npm": "deno run -A scripts/build_npm.ts $(git describe --tags --always --dirty)",
"test": "deno test -A --parallel --shuffle --doc --coverage=.coverage",
"check": "deno check ./**/*.ts",
"coverage": "deno coverage .coverage",
"upgrade": "deno run -q -A https://deno.land/x/molt@0.14.2/cli.ts ./**/*.ts",
"upgrade:commit": "deno task -q upgrade --commit --prefix :package: --pre-commit=fmt"
"test": "deno test -A --parallel --shuffle --doc --coverage=.coverage",
"coverage": "deno coverage .coverage"
},
"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"
}
}
17 changes: 10 additions & 7 deletions error_object.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import {
is,
PredicateType,
} from "https://deno.land/x/unknownutil@v3.11.0/mod.ts";
import { is, type Predicate } from "@core/unknownutil";

export const isErrorObject = is.ObjectOf({
export type ErrorObject = {
proto: string;
name: string;
message: string;
stack?: string;
attributes: Record<string, unknown>;
};

export const isErrorObject: Predicate<ErrorObject> = is.ObjectOf({
proto: is.String,
name: is.String,
message: is.String,
stack: is.OptionalOf(is.String),
attributes: is.Record,
});

export type ErrorObject = PredicateType<typeof isErrorObject>;

/**
* Convert an error to an error object
*/
Expand Down
5 changes: 1 addition & 4 deletions error_object_test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
assertEquals,
assertInstanceOf,
} from "https://deno.land/std@0.210.0/assert/mod.ts";
import { assertEquals, assertInstanceOf } from "@std/assert";
import { fromErrorObject, toErrorObject } from "./error_object.ts";

class CustomError extends Error {
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 "https://deno.land/std@0.210.0/assert/mod.ts";
import { assertThrows } from "@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 "https://deno.land/x/dnt@0.39.0/mod.ts";
import { build, emptyDir } from "@deno/dnt";

const name = "@lambdalisue/errorutil";
const version = Deno.args[0];
Expand Down
6 changes: 1 addition & 5 deletions try_or_test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
assertEquals,
assertRejects,
assertThrows,
} from "https://deno.land/std@0.210.0/assert/mod.ts";
import { assertEquals, assertRejects, assertThrows } from "@std/assert";
import { raise } from "./raise.ts";
import { tryOr, tryOrElse } from "./try_or.ts";

Expand Down

0 comments on commit 8d22e9a

Please sign in to comment.