Skip to content

Commit

Permalink
chore: clean up scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd committed Dec 2, 2024
1 parent 1124cd3 commit b642817
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
1 change: 1 addition & 0 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@ast-grep/napi": "npm:@ast-grep/napi@^0.31.0",
"@luca/esbuild-deno-loader": "jsr:@luca/esbuild-deno-loader@^0.11.0",
"@std/assert": "jsr:@std/assert@^1.0.8",
"@std/fs": "jsr:@std/fs@^1.0.6",
"esbuild": "npm:esbuild@^0.24.0",
"prettier": "npm:prettier@^3.4.1",
"typescript": "npm:typescript@^5.7.2",
Expand Down
11 changes: 10 additions & 1 deletion deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 2 additions & 8 deletions scripts/build.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
import { denoPlugins } from '@luca/esbuild-deno-loader'
import { emptyDir } from '@std/fs'
import * as esbuild from 'esbuild'
import tsid from 'unplugin-isolated-decl/esbuild'
import denoJson from '../deno.json' with { type: 'json' }

try {
await Deno.remove('dist', { recursive: true })
await Deno.mkdir('dist')
} catch (err) {
if (!(err instanceof Deno.errors.NotFound)) {
throw err
}
}
await emptyDir('dist')

await esbuild.build({
plugins: [
Expand Down
9 changes: 2 additions & 7 deletions scripts/patch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Lang, parse } from '@ast-grep/napi'
import { ensureDir } from '@std/fs'
import denoJson from '../deno.json' with { type: 'json' }

const version = denoJson.imports.prettier.split('@')[1]
Expand All @@ -18,13 +19,7 @@ const n2$D = node2.getMatch('D')!.text()
const edit1 = node2.replace(`${n2$A}.use(${n2$D}).use`)
const transformed = root.commitEdits([edit1]).toString()

try {
await Deno.mkdir('./vendor', { recursive: true })
} catch (err) {
if (!(err instanceof Deno.errors.AlreadyExists)) {
throw err
}
}
await ensureDir('vendor')

await Deno.writeTextFile('./vendor/prettier-plugin-markdown.js', transformed)
await Deno.writeTextFile(
Expand Down

0 comments on commit b642817

Please sign in to comment.