Skip to content

Commit 79847e1

Browse files
fix: README
1 parent ba8f5af commit 79847e1

File tree

3 files changed

+22
-77
lines changed

3 files changed

+22
-77
lines changed

README.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1-
#!/usr/bin/env -S deno run --allow-read --allow-run=bash,git,cargo --allow-net=docs.rs:443 --allow-env --allow-sys
1+
#!/usr/bin/env -S deno run --allow-write --allow-read --allow-run=bash,git,cargo --allow-net=docs.rs:443 --allow-env --allow-sys --no-lock
22

3-
import * as zx from "npm:zx"
3+
// NOTE: Pin the versions of the packages because the script runs without a lock file
4+
import * as zx from "npm:zx@8.3.2"
45
import { z, ZodSchema, ZodTypeDef } from "https://deno.land/x/zod@v3.23.8/mod.ts"
56
import { assert, assertEquals } from "jsr:@std/assert@1.0.0"
67
import { toSnakeCase } from "jsr:@std/text@1.0.10"
8+
import { parseArgs } from "jsr:@std/cli@1.0.13"
9+
10+
export const args = parseArgs(Deno.args, {
11+
string: ["output"],
12+
alias: {
13+
output: "o",
14+
},
15+
})
716

817
const CargoTomlSchema = z.object({
918
package: z.object({
@@ -165,7 +174,7 @@ Unless you explicitly state otherwise, any contribution intentionally submitted
165174

166175
const body = renderNonEmptySections(sections)
167176

168-
console.info(`
177+
const content = `
169178
<!-- DO NOT EDIT -->
170179
<!-- This file is automatically generated by README.ts. -->
171180
<!-- Edit README.ts if you want to make changes. -->
@@ -174,4 +183,12 @@ console.info(`
174183
175184
${titleSectionBody}
176185
177-
${body}`.trim())
186+
${body}`.trim()
187+
188+
if (args.output) {
189+
const encoder = new TextEncoder()
190+
const bytes = encoder.encode(content + "\n")
191+
await Deno.writeFile(args.output, bytes)
192+
} else {
193+
console.info(content)
194+
}

deno.lock

Lines changed: 0 additions & 72 deletions
This file was deleted.

mise.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ run = "cargo check --all-targets"
6666
run = "cargo fix --workspace --allow-dirty --allow-staged"
6767

6868
[tasks."gen:readme"]
69-
run = "./README.ts > README.md"
69+
run = "./README.ts --output README.md"
7070
sources = ["README.ts"]
7171
outputs = ["README.md"]
7272

0 commit comments

Comments
 (0)