diff --git a/lib/flowLSP/utils/getVerifiedFlowBinPath.js b/lib/flowLSP/utils/getVerifiedFlowBinPath.js index aabb638..84d0ddd 100644 --- a/lib/flowLSP/utils/getVerifiedFlowBinPath.js +++ b/lib/flowLSP/utils/getVerifiedFlowBinPath.js @@ -22,7 +22,7 @@ function getFlowBinDirPrefixForPlatform(): null | string { null; } -async function getFlowBinRelativePath(flowBinModulePath: string): Promise { +async function getFlowBinRelativePath(flowBinModulePath: string): Promise<{|flowBinDirName: string, flowBinName: string|}> { const dirPrefix = getFlowBinDirPrefixForPlatform(); if (!dirPrefix) { throw new Error(`Failed to determine correct binary for platform ${process.platform} and arch ${process.arch}`); @@ -38,7 +38,7 @@ async function getFlowBinRelativePath(flowBinModulePath: string): Promise { @@ -59,7 +59,8 @@ async function getShasums(flowBinModulePath: string, logger: Logger): Promise line.includes(flowBinRelativePath)); if (!shasum_line) { @@ -74,8 +75,8 @@ export default async function(flowBinModulePath: string, logger: Logger): Promis const shasums = await getShasums(flowBinModulePath, logger); // successfully verified SHASUM256.txt, now we can use it to verify the flow binary - const flowBinRelativePath = await getFlowBinRelativePath(flowBinModulePath); - const flowBinPath = path.join(flowBinModulePath, flowBinRelativePath); + const {flowBinDirName, flowBinName} = await getFlowBinRelativePath(flowBinModulePath); + const flowBinPath = path.join(flowBinModulePath, flowBinDirName, flowBinName); const hash = createHash('sha256'); const flowBinReadStream = createReadStream(flowBinPath); const flowBinHashPromise = new Promise((resolve, reject) => { @@ -84,7 +85,7 @@ export default async function(flowBinModulePath: string, logger: Logger): Promis }); flowBinReadStream.pipe(hash); const flowBinHash = await flowBinHashPromise; - const shasum = getShasum(shasums.toString(), flowBinRelativePath); + const shasum = getShasum(shasums.toString(), flowBinDirName, flowBinName); if (flowBinHash !== shasum) { throw new Error( `Hash of ${flowBinPath} does not match hash from SHASUM256.txt:\n` +