Skip to content

Commit 6282bc9

Browse files
ospencerjaredly
authored andcommitted
Port old syntax build system (#331)
* Ignore typescript output * Add OCaml grammar source * Add typescript config * Add syntax build script * Add npm script to build syntaxes * Add OCaml grammar build instructions
1 parent 53c99e9 commit 6282bc9

File tree

9 files changed

+2919
-2
lines changed

9 files changed

+2919
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ tmp
2020
*.vsix
2121
examples/markdown-reason-react/
2222
editor-extensions/vscode/*.zip
23+
editor-extensions/vscode/src/syntaxes/out
2324
bsb_modules
2425
_esy/
2526
bin.exe

Readme.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ I had a couple of reasons for starting a new one. The biggest is that I wanted s
150150
- Install the VS Code extension's dependencies `cd editor-extensions/vscode && npm i && cd ../..`
151151
- Open this project in VS Code
152152

153+
### Building the OCaml grammar
154+
- Edit the files in editor-extensions/vscode/src/syntaxes
155+
- Run `cd editor-extensions/vscode && npm run build-syntaxes`
156+
153157
## To test your changes in one of the example projects
154158
- Open the "Debug" pane in VS Code. Select a debug target. Press "Run"
155159
- It should start up a window titled `[Extension development host]`

editor-extensions/vscode/package-lock.json

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

editor-extensions/vscode/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@
189189
]
190190
},
191191
"scripts": {
192-
"postinstall": "node ./node_modules/vscode/bin/install"
192+
"postinstall": "node ./node_modules/vscode/bin/install",
193+
"build-syntaxes": "tsc -p src/syntaxes && node script/syntax.js"
193194
},
194195
"dependencies": {
195196
"vscode": "^1.1.17",
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env node
2+
3+
const fs = require("fs");
4+
const path = require("path");
5+
const languages = ["ocaml"];
6+
7+
function inPath(language) {
8+
return path.resolve(".", "src", "syntaxes", "out", language);
9+
}
10+
11+
function outPath(language) {
12+
return path.resolve(".", `${language}.json`);
13+
}
14+
15+
for (const language of languages) {
16+
const from = inPath(language);
17+
const into = outPath(language);
18+
const data = require(from);
19+
const json = JSON.stringify(data.default);
20+
fs.writeFileSync(into, json);
21+
}

0 commit comments

Comments
 (0)