Skip to content

Commit 8083e73

Browse files
committed
Use promisify to support node 8
1 parent 6bb64d7 commit 8083e73

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

server/src/analyser.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import {promises as fs} from 'fs'
1+
import * as fs from 'fs'
22
import * as FuzzySearch from 'fuzzy-search'
33
import * as request from 'request-promise-native'
44
import * as URI from 'urijs'
5+
import { promisify } from 'util'
56
import * as LSP from 'vscode-languageserver'
67
import * as Parser from 'web-tree-sitter'
78

@@ -13,6 +14,8 @@ import { getFilePaths } from './util/fs'
1314
import { getShebang, isBashShebang } from './util/shebang'
1415
import * as TreeSitterUtil from './util/tree-sitter'
1516

17+
const readFileAsync = promisify(fs.readFile)
18+
1619
type Kinds = { [type: string]: LSP.SymbolKind }
1720

1821
type Declarations = { [name: string]: LSP.SymbolInformation[] }
@@ -67,7 +70,7 @@ export default class Analyzer {
6770
connection.console.log(`Analyzing ${uri}`)
6871

6972
try {
70-
const fileContent = await fs.readFile(filePath, 'utf8')
73+
const fileContent = await readFileAsync(filePath, 'utf8')
7174
const shebang = getShebang(fileContent)
7275
if (shebang && !isBashShebang(shebang)) {
7376
connection.console.log(`Skipping file ${uri} with shebang "${shebang}"`)

0 commit comments

Comments
 (0)