@@ -22,7 +22,7 @@ function getFlowBinDirPrefixForPlatform(): null | string {
2222 null ;
2323}
2424
25- async function getFlowBinRelativePath ( flowBinModulePath : string ) : Promise < string > {
25+ async function getFlowBinRelativePath ( flowBinModulePath : string ) : Promise < { | flowBinDirName: string , flowBinName : string | } > {
2626 const dirPrefix = getFlowBinDirPrefixForPlatform ( ) ;
2727 if ( ! dirPrefix ) {
2828 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<string
3838 if ( ! flowBinName ) {
3939 throw new Error ( `Failed to find flow binary in ${ flowBinDir } ` ) ;
4040 }
41- return path . join ( flowBinDirName , flowBinName ) ;
41+ return { flowBinDirName, flowBinName} ;
4242}
4343
4444async function getShasums ( flowBinModulePath : string , logger : Logger ) : Promise < Buffer > {
@@ -59,7 +59,8 @@ async function getShasums(flowBinModulePath: string, logger: Logger): Promise<Bu
5959 }
6060}
6161
62- function getShasum ( shasums : string , flowBinRelativePath : string ) : string {
62+ function getShasum ( shasums : string , flowBinDirName : string , flowBinName : string ) : string {
63+ const flowBinRelativePath = `${ flowBinDirName } /${ flowBinName } ` ;
6364 const shasum_lines = shasums . split ( / \r ? \n / ) ;
6465 const shasum_line = shasum_lines . find ( line => line . includes ( flowBinRelativePath ) ) ;
6566 if ( ! shasum_line ) {
@@ -74,8 +75,8 @@ export default async function(flowBinModulePath: string, logger: Logger): Promis
7475 const shasums = await getShasums ( flowBinModulePath , logger ) ;
7576
7677 // successfully verified SHASUM256.txt, now we can use it to verify the flow binary
77- const flowBinRelativePath = await getFlowBinRelativePath ( flowBinModulePath ) ;
78- const flowBinPath = path . join ( flowBinModulePath , flowBinRelativePath ) ;
78+ const { flowBinDirName , flowBinName } = await getFlowBinRelativePath ( flowBinModulePath ) ;
79+ const flowBinPath = path . join ( flowBinModulePath , flowBinDirName , flowBinName ) ;
7980 const hash = createHash ( 'sha256' ) ;
8081 const flowBinReadStream = createReadStream ( flowBinPath ) ;
8182 const flowBinHashPromise = new Promise ( ( resolve , reject ) => {
@@ -84,7 +85,7 @@ export default async function(flowBinModulePath: string, logger: Logger): Promis
8485 } ) ;
8586 flowBinReadStream . pipe ( hash ) ;
8687 const flowBinHash = await flowBinHashPromise ;
87- const shasum = getShasum ( shasums . toString ( ) , flowBinRelativePath ) ;
88+ const shasum = getShasum ( shasums . toString ( ) , flowBinDirName , flowBinName ) ;
8889 if ( flowBinHash !== shasum ) {
8990 throw new Error (
9091 `Hash of ${ flowBinPath } does not match hash from SHASUM256.txt:\n` +
0 commit comments