@@ -14,15 +14,22 @@ const plist = require("plist");
1414const srcFile = path . join ( __dirname , "src" , "qsharp.tmLanguage.yml" ) ;
1515const grammarsDir = path . join ( __dirname , "grammars" ) ;
1616
17+ // JSON Schema for TextMate grammars. Emitted only into the JSON outputs (as the
18+ // first key)
19+ const JSON_SCHEMA = "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json" ;
20+
1721function build ( ) {
1822 const text = fs . readFileSync ( srcFile , "utf8" ) ;
1923 const grammar = jsYaml . load ( text ) ;
2024
25+ const jsonGrammar = { $schema : JSON_SCHEMA , ...grammar } ;
26+ const jsonText = JSON . stringify ( jsonGrammar , null , "\t" ) + "\n" ;
27+
2128 fs . mkdirSync ( grammarsDir , { recursive : true } ) ;
2229
2330 fs . writeFileSync (
2431 path . join ( grammarsDir , "qsharp.tmLanguage.json" ) ,
25- JSON . stringify ( grammar , null , "\t" ) + "\n"
32+ jsonText
2633 ) ;
2734
2835 fs . writeFileSync (
@@ -38,7 +45,7 @@ function build() {
3845 if ( fs . existsSync ( testExtDir ) ) {
3946 fs . writeFileSync (
4047 path . join ( testExtDir , "qsharp.tmLanguage.json" ) ,
41- JSON . stringify ( grammar , null , "\t" ) + "\n"
48+ jsonText
4249 ) ;
4350 console . log ( "Refreshed test-extension/qsharp.tmLanguage.json" ) ;
4451 }
0 commit comments