File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ const BB = require('bluebird')
55const cacache = require ( 'cacache' )
66const Fetcher = require ( '../fetch' )
77const fs = require ( 'fs' )
8- const pipe = require ( 'mississippi' ) . pipe
8+ const pipe = BB . promisify ( require ( 'mississippi' ) . pipe )
99const through = require ( 'mississippi' ) . through
1010
1111const readFileAsync = BB . promisify ( fs . readFile )
@@ -50,7 +50,19 @@ Fetcher.impl(fetchFile, {
5050 } )
5151 } )
5252 } else {
53- return pipe ( fs . createReadStream ( src ) , stream )
53+ let integrity
54+ const cacheWriter = ! opts . cache
55+ ? BB . resolve ( null )
56+ : ( pipe (
57+ fs . createReadStream ( src ) ,
58+ cacache . put . stream ( opts . cache , `pacote:tarball:${ src } ` , {
59+ integrity : opts . integrity
60+ } ) . on ( 'integrity' , d => { integrity = d } )
61+ ) )
62+ return cacheWriter . then ( ( ) => {
63+ if ( integrity ) { stream . emit ( 'integrity' , integrity ) }
64+ return pipe ( fs . createReadStream ( src ) , stream )
65+ } )
5466 }
5567 } , err => stream . emit ( 'error' , err ) )
5668 return stream
You can’t perform that action at this time.
0 commit comments