Skip to content

Commit

Permalink
Port old syntax build system (#331)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ospencer authored and jaredly committed Sep 20, 2019
1 parent 53c99e9 commit 6282bc9
Show file tree
Hide file tree
Showing 9 changed files with 2,919 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ tmp
*.vsix
examples/markdown-reason-react/
editor-extensions/vscode/*.zip
editor-extensions/vscode/src/syntaxes/out
bsb_modules
_esy/
bin.exe
Expand Down
4 changes: 4 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ I had a couple of reasons for starting a new one. The biggest is that I wanted s
- Install the VS Code extension's dependencies `cd editor-extensions/vscode && npm i && cd ../..`
- Open this project in VS Code

### Building the OCaml grammar
- Edit the files in editor-extensions/vscode/src/syntaxes
- Run `cd editor-extensions/vscode && npm run build-syntaxes`

## To test your changes in one of the example projects
- Open the "Debug" pane in VS Code. Select a debug target. Press "Run"
- It should start up a window titled `[Extension development host]`
Expand Down
8 changes: 7 additions & 1 deletion editor-extensions/vscode/package-lock.json

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

3 changes: 2 additions & 1 deletion editor-extensions/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@
]
},
"scripts": {
"postinstall": "node ./node_modules/vscode/bin/install"
"postinstall": "node ./node_modules/vscode/bin/install",
"build-syntaxes": "tsc -p src/syntaxes && node script/syntax.js"
},
"dependencies": {
"vscode": "^1.1.17",
Expand Down
21 changes: 21 additions & 0 deletions editor-extensions/vscode/script/syntax.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env node

const fs = require("fs");
const path = require("path");
const languages = ["ocaml"];

function inPath(language) {
return path.resolve(".", "src", "syntaxes", "out", language);
}

function outPath(language) {
return path.resolve(".", `${language}.json`);
}

for (const language of languages) {
const from = inPath(language);
const into = outPath(language);
const data = require(from);
const json = JSON.stringify(data.default);
fs.writeFileSync(into, json);
}
Loading

0 comments on commit 6282bc9

Please sign in to comment.