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

chore: switch to jsr #37

Merged
merged 6 commits into from
Mar 4, 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
4 changes: 2 additions & 2 deletions .bmp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ commit: Bump to version v%.%.%
files:
README.md:
- license_checker v%.%.%
- license_checker@v%.%.%/main.ts
- license_checker@v%.%.%/lib.ts
- '@kt3k/license_checker@%.%.%'
main.ts: console.log("%.%.%")
dnt.ts: 'version: "%.%.%"'
deno.json: '"version": "%.%.%"'
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ A utility for checking license headers in the files in a directory.
Use via Deno:

```shell
deno run --allow-read https://deno.land/x/license_checker@v3.2.3/main.ts
deno run --allow-read jsr:@kt3k/license_checker@3.2.3
```

Use via npx:
Expand All @@ -34,7 +34,7 @@ Create `.licenserc.json` like the following:
Then run:

```console
deno run --allow-read https://deno.land/x/license_checker@v3.2.3/main.ts
deno run --allow-read jsr:@kt3k/license_checker@3.2.3
```

This checks the license lines in the files under the current directory.
Expand Down Expand Up @@ -125,7 +125,7 @@ Options:
# API

```ts
import { checkLicense } from "https://deno.land/x/license_checker@v3.2.3/lib.ts";
import { checkLicense } from "jsr:@kt3k/license_checker@3.2.3/lib";
```

## `checkLicense(configs: Config[], options: Options): Promise<boolean>`
Expand Down
6 changes: 6 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{
"name": "@kt3k/license_checker",
"version": "3.2.3",
"exports": {
".": "./lib.ts",
"./main": "./main.ts"
},
"tasks": {
"test": "deno test --unstable --allow-read --allow-write --allow-run --allow-net=0.0.0.0:8000 test.ts",
"cov": "deno test --coverage=coverage --unstable --allow-read --allow-write --allow-run --allow-net=0.0.0.0:8000 test.ts && deno coverage --unstable --lcov coverage > coverage/lcov.info",
Expand Down
14 changes: 7 additions & 7 deletions deps.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright 2020-2022 Yoshiya Hinosawa. All rights reserved. MIT license.

export { parseArgs as parse } from "https://deno.land/std@0.211.0/cli/parse_args.ts";
export { blue, green, red } from "https://deno.land/std@0.211.0/fmt/colors.ts";
export { expandGlob } from "https://deno.land/std@0.211.0/fs/expand_glob.ts";
export { relative } from "https://deno.land/std@0.211.0/path/relative.ts";
export { includesNeedle as contains } from "https://deno.land/std@0.211.0/bytes/includes_needle.ts";
export { copy } from "https://deno.land/std@0.211.0/streams/copy.ts";
export { delay } from "https://deno.land/std@0.211.0/async/delay.ts";
export { parseArgs as parse } from "jsr:@std/cli@0.218.0/parse_args";
export { blue, green, red } from "jsr:@std/fmt@0.218.0/colors";
export { expandGlob } from "jsr:@std/fs@0.218.0/expand_glob";
export { relative } from "jsr:@std/path@0.218.0/relative";
export { includesNeedle as contains } from "jsr:@std/bytes@0.218.0/includes_needle";
export { copy } from "jsr:@std/io@0.218.0/copy";
export { delay } from "jsr:@std/async@0.218.0/delay";
14 changes: 8 additions & 6 deletions lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import {
relative,
} from "./deps.ts";

const decoder = new TextDecoder();
const decode = (data: Uint8Array) => decoder.decode(data);
const decoder: TextDecoder = new TextDecoder();
const decode: (data: Uint8Array) => string = (data: Uint8Array) =>
decoder.decode(data);

const encoder = new TextEncoder();
const encode = (str: string) => encoder.encode(str);
const encoder: TextEncoder = new TextEncoder();
const encode: (str: string) => Uint8Array = (str: string) =>
encoder.encode(str);

type LicenseLines = string | string[];

Expand All @@ -39,8 +41,8 @@ const checkFile = async (
const file = await Deno.open(filename, { read: true });
// We assume copyright header appears in first 8KB of each file.
const sourceCode = new Uint8Array(8192);
await Deno.read(file.rid, sourceCode);
Deno.close(file.rid);
await file.read(sourceCode);
file.close();

if (copyrightLines.every((line) => contains(sourceCode, line))) {
if (!quiet) {
Expand Down
Loading