Skip to content

Commit

Permalink
use fs instead of fs/promises for compatibility with older vscode ver…
Browse files Browse the repository at this point in the history
…sions
  • Loading branch information
Vijay Ramamurthy committed Jul 12, 2021
1 parent 64f5ee5 commit 00a4ff0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/flowLSP/utils/getVerifiedFlowBinPath.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
import Logger from './Logger';
import importFresh from './importFresh';
import getExtensionPath from './getExtentionPath';
// $FlowFixMe Flow doesn't recognize the fs/promises node module
import { readFile, readdir, access } from 'fs/promises';
import { promises } from 'fs';
import { createReadStream } from 'fs';
import path from 'path';
// $FlowFixMe Flow doesn't recognize crypto.verify
import { verify, createHash } from 'crypto';
import { window } from 'vscode';

// fs/promises
const { readFile, readdir, access } = promises;

function getFlowBinDirPrefixForPlatform(): null | string {
return process.platform === 'darwin'
? 'flow-osx-v' :
Expand Down Expand Up @@ -44,7 +46,7 @@ async function getShasums(flowBinModulePath: string, logger: Logger): Promise<Bu
try {
// try veryifying against SHASUM256.txt.sign
const shasums = await readFile(path.join(flowBinModulePath, 'SHASUM256.txt'));
const shasumsSignatureBase64 = await readFile(path.join(flowBinModulePath, 'SHASUM256.txt.sign'), { encoding: 'ascii' });
const shasumsSignatureBase64 = await readFile(path.join(flowBinModulePath, 'SHASUM256.txt.sign'), 'ascii' );
const shasumsSignature = Buffer.from(shasumsSignatureBase64, 'base64');
const publicKey = await readFile(path.join(extensionPath, 'signing.pem'));
if (!verify('sha256', shasums, publicKey, shasumsSignature)) {
Expand Down

0 comments on commit 00a4ff0

Please sign in to comment.