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"
45import { z , ZodSchema , ZodTypeDef } from "https://deno.land/x/zod@v3.23.8/mod.ts"
56import { assert , assertEquals } from "jsr:@std/assert@1.0.0"
67import { 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
817const CargoTomlSchema = z . object ( {
918 package : z . object ( {
@@ -165,7 +174,7 @@ Unless you explicitly state otherwise, any contribution intentionally submitted
165174
166175const 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+ }
0 commit comments