From 964453f3834874b98350e5bf77fcd15db159d57d Mon Sep 17 00:00:00 2001 From: Remy Suen Date: Thu, 14 Mar 2019 10:37:04 -0400 Subject: [PATCH 1/2] Only analyze files that end with .sh in their names Skip out on trying to parse directories that have a .sh suffix in their names. Otherwise, the language server will crash when trying to read a directory as a file. Signed-off-by: Remy Suen --- server/src/analyser.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/server/src/analyser.ts b/server/src/analyser.ts index 9556c2c66..61c89d66b 100644 --- a/server/src/analyser.ts +++ b/server/src/analyser.ts @@ -51,12 +51,15 @@ export default class Analyzer { const analyzer = new Analyzer() paths.forEach(p => { const absolute = Path.join(rootPath, p) - const uri = 'file://' + absolute - connection.console.log('Analyzing ' + uri) - analyzer.analyze( - uri, - LSP.TextDocument.create(uri, 'shell', 1, fs.readFileSync(absolute, 'utf8')), - ) + // only analyze files, glob pattern may match directories + if (fs.existsSync(absolute) && fs.lstatSync(absolute).isFile()) { + const uri = 'file://' + absolute + connection.console.log('Analyzing ' + uri) + analyzer.analyze( + uri, + LSP.TextDocument.create(uri, 'shell', 1, fs.readFileSync(absolute, 'utf8')), + ) + } }) resolve(analyzer) } From e30a0e4863c536a54467f74ccb5520954261c5f9 Mon Sep 17 00:00:00 2001 From: Remy Suen Date: Thu, 14 Mar 2019 10:46:36 -0400 Subject: [PATCH 2/2] Format the code to fix a linting error Signed-off-by: Remy Suen --- server/src/analyser.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/src/analyser.ts b/server/src/analyser.ts index 61c89d66b..70ff69a71 100644 --- a/server/src/analyser.ts +++ b/server/src/analyser.ts @@ -57,7 +57,12 @@ export default class Analyzer { connection.console.log('Analyzing ' + uri) analyzer.analyze( uri, - LSP.TextDocument.create(uri, 'shell', 1, fs.readFileSync(absolute, 'utf8')), + LSP.TextDocument.create( + uri, + 'shell', + 1, + fs.readFileSync(absolute, 'utf8'), + ), ) } })