@@ -2,7 +2,7 @@ const _ = require('lodash')
22const arch = require ( 'arch' )
33const os = require ( 'os' )
44const ospath = require ( 'ospath' )
5- const crypto = require ( 'crypto ' )
5+ const hasha = require ( 'hasha ' )
66const la = require ( 'lazy-ass' )
77const is = require ( 'check-more-types' )
88const tty = require ( 'tty' )
@@ -30,31 +30,11 @@ const getosAsync = Promise.promisify(getos)
3030
3131/**
3232 * Returns SHA512 of a file
33- *
34- * Implementation lifted from https://github.com/sindresorhus/hasha
35- * but without bringing that dependency (since hasha is Node v8+)
3633 */
3734const getFileChecksum = ( filename ) => {
3835 la ( is . unemptyString ( filename ) , 'expected filename' , filename )
3936
40- const hashStream = ( ) => {
41- const s = crypto . createHash ( 'sha512' )
42-
43- s . setEncoding ( 'hex' )
44-
45- return s
46- }
47-
48- return new Promise ( ( resolve , reject ) => {
49- const stream = fs . createReadStream ( filename )
50-
51- stream . on ( 'error' , reject )
52- . pipe ( hashStream ( ) )
53- . on ( 'error' , reject )
54- . on ( 'finish' , function ( ) {
55- resolve ( this . read ( ) )
56- } )
57- } )
37+ return hasha . fromFile ( filename , { algorithm : 'sha512' } )
5838}
5939
6040const getFileSize = ( filename ) => {
0 commit comments