Skip to content

Commit

Permalink
chore: support force fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Dec 21, 2023
1 parent 3c178c8 commit 57cd072
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"bump": "esno scripts/bump.ts",
"test": "vitest",
"fetch": "esno scripts/fetch.ts && eslint . --fix",
"fetch:force": "esno scripts/fetch.ts --force && eslint . --fix",
"typecheck": "tsc --noEmit",
"prepare": "simple-git-hooks"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/tm-grammars/grammars/mdc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"displayName": "mdc",
"displayName": "MDC",
"injectionSelector": "L:text.html.markdown",
"name": "mdc",
"patterns": [
Expand Down
3 changes: 2 additions & 1 deletion packages/tm-grammars/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1191,6 +1191,7 @@ export const grammars = [
'md',
],
categories: [
'web',
'markup',
],
displayName: 'Markdown',
Expand Down Expand Up @@ -1285,7 +1286,7 @@ export const grammars = [
'web',
'markup',
],
displayName: 'mdc',
displayName: 'MDC',
embedded: [
'markdown',
'yaml',
Expand Down
9 changes: 6 additions & 3 deletions scripts/grammars/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs from 'node:fs/promises'
import process from 'node:process'
import { fetch } from 'ofetch'
import pLimit from 'p-limit'
import c from 'chalk'
Expand All @@ -23,9 +24,11 @@ const limit = pLimit(25)

const scopeToGrammar = new Map<string, GrammarInfo>()

const oldMeta = await import('../../packages/tm-grammars/index.js')
.then(m => [...m.grammars, ...m.injections])
.catch(() => [] as GrammarInfo[])
const oldMeta = process.argv.includes('--force')
? []
: await import('../../packages/tm-grammars/index.js')
.then(m => [...m.grammars, ...m.injections])
.catch(() => [] as GrammarInfo[])

let changed = false

Expand Down
9 changes: 6 additions & 3 deletions scripts/themes/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs from 'node:fs/promises'
import process from 'node:process'
import pLimit from 'p-limit'
import stringify from 'json-stable-stringify'
import c from 'chalk'
Expand All @@ -17,9 +18,11 @@ const dirOutput = new URL('../../packages/tm-themes/themes/', import.meta.url)

await fs.mkdir(dirOutput, { recursive: true })

const oldMeta = await import('../../packages/tm-themes/index.js')
.then(m => m.themes)
.catch(() => [] as ThemeInfo[])
const oldMeta = process.argv.includes('--force')
? []
: await import('../../packages/tm-themes/index.js')
.then(m => m.themes)
.catch(() => [] as ThemeInfo[])

let changed = false

Expand Down
1 change: 1 addition & 0 deletions sources-grammars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ export const sourcesCommunity: GrammarSource[] = [
},
{
name: 'mdc',
displayName: 'MDC',
source: 'https://github.com/nuxtlabs/vscode-mdc/blob/main/syntaxes/mdc.tmLanguage.json',
categories: ['web', 'markup'],
},
Expand Down

0 comments on commit 57cd072

Please sign in to comment.