Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support JSR #3

Merged
merged 1 commit into from
Apr 6, 2024
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
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
8 changes: 6 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ on:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
with:
deno-version: ${{ env.DENO_VERSION }}
Expand All @@ -30,11 +31,14 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
with:
deno-version: ${{ env.DENO_VERSION }}
- name: Test
run: |
deno task test
timeout-minutes: 5
- name: JSR publish (dry-run)
run: |
deno publish --dry-run
50 changes: 0 additions & 50 deletions .github/workflows/udd.yml

This file was deleted.

15 changes: 4 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# unnullish

[![jsr](https://img.shields.io/jsr/v/%40lambdalisue/unnullish?logo=javascript&logoColor=white)](https://jsr.io/@lambdalisue/unnullish)
[![denoland](https://img.shields.io/github/v/release/lambdalisue/deno-unnullish?logo=deno&label=denoland)](https://github.com/lambdalisue/deno-unnullish/releases)
[![npm](http://img.shields.io/badge/available%20on-npm-lightgrey.svg?logo=npm&logoColor=white)](https://www.npmjs.com/package/unnullish)
[![deno land](http://img.shields.io/badge/available%20on-deno.land/x-lightgrey.svg?logo=deno)](https://deno.land/x/unnullish)
[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/unnullish/mod.ts)
[![Test](https://github.com/lambdalisue/deno-unnullish/workflows/Test/badge.svg)](https://github.com/lambdalisue/deno-unnullish/actions?query=workflow%3ATest)
[![npm version](https://badge.fury.io/js/unnullish.svg)](https://badge.fury.io/js/unnullish)
Expand All @@ -23,7 +24,7 @@ The function is useful when you want to apply some transformation functions to
optional values. For example,

```typescript
import { unnullish } from "./mod.ts";
import { unnullish } from "https://deno.land/x/unnullish@$MODULE_VERSION/mod.ts";

type Options = {
foo?: string;
Expand Down Expand Up @@ -54,7 +55,7 @@ you may need to use nullish coalescing operator to normalize the result. For
example,

```typescript
import { unnullish } from "./mod.ts";
import { unnullish } from "https://deno.land/x/unnullish@$MODULE_VERSION/mod.ts";

console.log(unnullish(null, () => 0));
// -> undefined
Expand All @@ -67,14 +68,6 @@ console.log(unnullish(undefined, () => 0) ?? null);
// -> null
```

##### Deno

Use `import { unnullish } from "https://deno.land/x/unnullish/mod.ts"`;

##### Node

Use `import { unnullish } from "unnullish"`;

## License

The code follows MIT license written in [LICENSE](./LICENSE). Contributors need
Expand Down
15 changes: 11 additions & 4 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
{
"lock": false,
"name": "@lambdalisue/unnullish",
"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 --unstable -A --parallel",
"check": "deno check --unstable $(find . -name '*.ts')",
"upgrade": "deno run -A https://deno.land/x/udd/main.ts $(find . -name '*.ts' -not -path '*/npm/*')"
"test": "deno test -A --parallel --doc --shuffle",
"check": "deno check **/*.ts"
},
"imports": {
"@deno/dnt": "jsr:@deno/dnt@^0.41.1",
"@lambdalisue/unreachable": "jsr:@lambdalisue/unreachable@^1.0.1",
"@std/assert": "jsr:@std/assert@^0.221.0",
"https://deno.land/x/unnullish@$MODULE_VERSION/": "./"
}
}
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.34.0/mod.ts";
import { build, emptyDir } from "@deno/dnt";

const name = "unnullish";
const version = Deno.args[0];
Expand Down
4 changes: 2 additions & 2 deletions unnullish_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assertEquals } from "https://deno.land/std@0.186.0/testing/asserts.ts";
import { unreachable } from "https://deno.land/x/unreachable@v0.1.0/mod.ts";
import { assertEquals } from "@std/assert";
import { unreachable } from "@lambdalisue/unreachable";
import { unnullish } from "./unnullish.ts";

Deno.test("unnullish() returns undefined when the value is undefined", () => {
Expand Down