44 *--------------------------------------------------------------------------------------------*/
55
66const cp = require ( 'child_process' ) ;
7- const npm = process . platform === 'win32' ? 'npm.cmd' : 'npm' ;
7+ const fs = require ( 'fs' ) ;
8+ const path = require ( 'path' ) ;
89
910function updateGrammar ( location ) {
11+ const npm = process . platform === 'win32' ? 'npm.cmd' : 'npm' ;
1012 const result = cp . spawnSync ( npm , [ 'run' , 'update-grammar' ] , {
1113 cwd : location ,
1214 stdio : 'inherit'
@@ -17,50 +19,17 @@ function updateGrammar(location) {
1719 }
1820}
1921
20- const extensions = [
21- 'bat' ,
22- 'clojure' ,
23- 'coffeescript' ,
24- 'cpp' ,
25- 'csharp' ,
26- 'css' ,
27- 'diff' ,
28- 'docker' ,
29- 'fsharp' ,
30- 'gitsyntax' ,
31- 'go' ,
32- 'groovy' ,
33- 'handlebars' ,
34- 'hlsl' ,
35- 'html' ,
36- 'ini' ,
37- 'java' ,
38- // 'javascript', updated through JavaScript
39- 'json' ,
40- 'less' ,
41- 'lua' ,
42- 'make' ,
43- 'markdown' ,
44- 'objective-c' ,
45- 'perl' ,
46- 'php' ,
47- 'powershell' ,
48- 'pug' ,
49- 'python' ,
50- 'r' ,
51- 'razor' ,
52- 'ruby' ,
53- 'rust' ,
54- 'scss' ,
55- 'shaderlab' ,
56- 'shellscript' ,
57- 'sql' ,
58- 'swift' ,
59- 'typescript' ,
60- 'vb' ,
61- 'xml' ,
62- 'yaml'
63- ] ;
22+ const allExtensionFolders = fs . readdirSync ( 'extensions' ) ;
23+ const extensions = allExtensionFolders . filter ( e => {
24+ try {
25+ let packageJSON = JSON . parse ( fs . readFileSync ( path . join ( 'extensions' , e , 'package.json' ) ) . toString ( ) ) ;
26+ return packageJSON && packageJSON . scripts && packageJSON . scripts [ 'update-grammar' ] ;
27+ } catch ( e ) {
28+ return false ;
29+ }
30+ } ) ;
31+
32+ console . log ( `Updating ${ extensions . length } grammars...` ) ;
6433
6534extensions . forEach ( extension => updateGrammar ( `extensions/${ extension } ` ) ) ;
6635
@@ -70,4 +39,5 @@ if (process.platform === 'win32') {
7039 cp . spawn ( '.\scripts\test-integration.bat' , [ ] , { env : process . env , stdio : 'inherit' } ) ;
7140} else {
7241 cp . spawn ( '/bin/bash' , [ './scripts/test-integration.sh' ] , { env : process . env , stdio : 'inherit' } ) ;
73- }
42+ }
43+
0 commit comments