1
- const fs = require ( 'fs' )
2
- const path = require ( 'path' )
3
- const vel = require ( 'vscode-extend-language' )
1
+ import fs from 'fs'
2
+ import path from 'path'
3
+ import { download , getCommitSha , expandConfigurationFile } from 'vscode-extend-language'
4
4
5
- const syntaxDir = path . join ( __dirname , '..' , ' syntax')
5
+ const syntaxDir = './ syntax'
6
6
7
+ /**
8
+ * Download a file from a specific branch on a repo
9
+ * @param {string } repo
10
+ * @param {string } file
11
+ * @param {string } version git branch to pull
12
+ */
7
13
async function downloadFile ( repo , file , version = 'main' ) {
8
14
const url = 'https://raw.githubusercontent.com/' + repo + '/' + version + '/' + file
9
- var content = await vel . download ( url )
15
+ var content = await download ( url )
10
16
if ( ! content ) {
11
17
console . log ( 'Cannot retrieve ' , url )
12
18
return
@@ -16,37 +22,50 @@ async function downloadFile(repo, file, version='main') {
16
22
console . log ( 'Updating' , syntaxFilePath )
17
23
}
18
24
19
- async function main ( ) {
25
+ async function updateGrammars ( ) {
20
26
const latexBasicsRepo = 'jlelong/vscode-latex-basics'
21
27
const grammarFiles = [
28
+ 'BibTeX-style.tmLanguage.json' ,
22
29
'Bibtex.tmLanguage.json' ,
30
+ 'DocTeX.tmLanguage.json' ,
31
+ 'JLweave.tmLanguage.json' ,
23
32
'LaTeX.tmLanguage.json' ,
33
+ 'Pweave.tmLanguage.json' ,
34
+ 'RSweave.tmLanguage.json' ,
24
35
'TeX.tmLanguage.json' ,
25
36
'cpp-grammar-bailout.tmLanguage.json' ,
26
37
'markdown-latex-combined.tmLanguage.json'
27
38
]
28
39
29
- const sha = await vel . getCommitSha ( latexBasicsRepo )
40
+ const sha = await getCommitSha ( latexBasicsRepo )
30
41
if ( sha ) {
31
42
console . log ( `Update grammar files to ${ latexBasicsRepo } @${ sha } ` )
32
43
} else {
33
44
console . log ( 'Cannot read last commit information' )
34
45
}
35
46
for ( const file of grammarFiles ) {
36
- downloadFile ( latexBasicsRepo , 'syntaxes/' + file )
47
+ await downloadFile ( latexBasicsRepo , 'syntaxes/' + file )
37
48
}
38
49
50
+ }
51
+
52
+ async function main ( ) {
53
+
54
+ await updateGrammars ( )
39
55
// The order of the files matters!
40
- languageFiles = [
56
+ const languageFiles = [
57
+ 'latex-language-configuration.json' ,
41
58
'latex-cpp-embedded-language-configuration.json' ,
42
59
'markdown-latex-combined-language-configuration.json' ,
43
- 'latex-language-configuration.json' ,
44
- 'latex3-language-configuration.json'
60
+ 'latex3-language-configuration.json' ,
61
+ 'bibtex-language-configuration.json' ,
62
+ 'bibtex-style-language-configuration.json' ,
63
+ 'doctex-language-configuration.json'
45
64
]
46
65
for ( const file of languageFiles ) {
47
66
console . log ( 'Expanding' , path . join ( syntaxDir , file ) )
48
- await vel . expandConfigurationFile ( path . join ( syntaxDir , 'src' , file ) , path . join ( syntaxDir , file ) )
67
+ await expandConfigurationFile ( path . join ( syntaxDir , 'src' , file ) , path . join ( syntaxDir , file ) )
49
68
}
50
69
}
51
70
52
- main ( )
71
+ await main ( )
0 commit comments