@@ -21,6 +21,7 @@ const glob = require("glob");
2121const fs = require ( "fs" ) ;
2222import * as Path from "path" ;
2323
24+ const pkg = require ( '../package' )
2425import * as Analyser from "./analyser" ;
2526
2627export function listen ( ) {
@@ -40,22 +41,25 @@ export function listen() {
4041 documents . listen ( connection ) ;
4142
4243 connection . onInitialize ( ( params ) : InitializeResult => {
44+
4345 connection . console . log (
44- `Initialized for ${ params . rootUri } , ${ params . rootPath } `
46+ `Initialized server v. ${ pkg . version } for ${ params . rootUri } `
4547 ) ;
4648
47- glob ( "**/*.sh" , { cwd : params . rootPath } , ( err , paths ) => {
48- if ( err != null ) {
49- connection . console . error ( err ) ;
50- } else {
51- paths . forEach ( p => {
52- const absolute = Path . join ( params . rootPath , p ) ;
53- const uri = "file://" + absolute ;
54- connection . console . log ( "Analyzing " + uri ) ;
55- Analyser . analyze ( uri , fs . readFileSync ( absolute , "utf8" ) ) ;
56- } ) ;
57- }
58- } ) ;
49+ if ( params . rootPath ) {
50+ glob ( "**/*.sh" , { cwd : params . rootPath } , ( err , paths ) => {
51+ if ( err != null ) {
52+ connection . console . error ( err ) ;
53+ } else {
54+ paths . forEach ( p => {
55+ const absolute = Path . join ( params . rootPath , p ) ;
56+ const uri = "file://" + absolute ;
57+ connection . console . log ( "Analyzing " + uri ) ;
58+ Analyser . analyze ( uri , fs . readFileSync ( absolute , "utf8" ) ) ;
59+ } ) ;
60+ }
61+ } ) ;
62+ }
5963
6064 return {
6165 capabilities : {
0 commit comments