Skip to content

Commit 37aba39

Browse files
committed
chore: move syntax build to separate file
1 parent df3c02f commit 37aba39

4 files changed

Lines changed: 11 additions & 14 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@
272272
"yaml": "^2.8.1"
273273
},
274274
"scripts": {
275-
"prebuild": "mkdir -p dist && bun run src/grammar/nix.ts && bun run src/grammar/injection.ts",
275+
"prebuild": "mkdir -p dist && bun run src/grammar/build.ts",
276276
"build": "bun build src/extension.ts --outdir=dist --external=vscode --target=node --format=cjs",
277277
"postinstall": "lefthook install",
278278
"clean": "rm -rd dist",

src/grammar/build.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// Generate json files from the grammar definitions.
2+
3+
import * as helpers from "./helpers";
4+
import { nixInjectionGrammar } from "./injection";
5+
import { source_nix } from "./nix";
6+
7+
// This code only runs when 'bun run index.ts' is executed directly.
8+
helpers.toJson("dist/injection.json", nixInjectionGrammar);
9+
helpers.toJson("dist/nix.tmLanguage.json", source_nix);

src/grammar/injection.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import * as helpers from "./helpers";
2-
3-
const nixInjectionGrammar = {
1+
export const nixInjectionGrammar = {
42
fileTypes: [],
53
injectionSelector: "L:text.html.markdown",
64
patterns: [
@@ -45,8 +43,3 @@ const nixInjectionGrammar = {
4543
},
4644
scopeName: "markdown.nix.codeblock",
4745
};
48-
49-
if (import.meta.main) {
50-
// This code only runs when 'bun run index.ts' is executed directly.
51-
helpers.toJson("dist/injection.json", nixInjectionGrammar);
52-
}

src/grammar/nix.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,8 +1238,3 @@ export const source_nix = {
12381238
},
12391239
},
12401240
};
1241-
1242-
if (import.meta.main) {
1243-
// This code only runs when 'bun run index.ts' is executed directly.
1244-
helpers.toJson("dist/nix.tmLanguage.json", source_nix);
1245-
}

0 commit comments

Comments
 (0)