nl_tokens: / * istanbul ignore next
pl_tokens: function extract ( checksumVerify , filename , sdkStream , root , strip , name , decompress ) { return tmpdir ( ) . then ( destdir => { // Exract tarball to destination. var extract = tar . extract ( destdir . path , { strip : strip , ignore : function ( <mask> ) { // Ignore self-directory. return path . normalize ( name + '/' ) === path . normalize ( destdir . path + '/' ) ; } } ) ; return new Promise ( ( resolve , reject ) => { var checksum = '' ; sdkStream . pipe ( sha256stream ( ) ) . on ( 'sha256' , function ( sha256 ) { checksum = sha256file ( sha256 , filename ) ; } ) . pipe ( decompress ) // tar-stream has a recursion issue when input chunks are too big. // by splitting up the chunks, we never get too deeply nested in the // stack. . pipe ( blocks ( { size : 64 * 1024 , zeroPadding : false } ) ) . pipe ( extract ) . on ( 'finish' , ( ) => { // Check sum. if ( checksum !== checksumVerify ) { return reject ( tags . stripIndent ` ${ name } ${ checksumVerify } ${ checksum } ` ) ; } // Write out CHECKSUM file. fs . writeFileSync ( path . join ( destdir . path , 'CHECKSUM' ) , checksum ) ; try { // Remove the old SDK directory. fs . removeSync ( root ) ; // Move temporary directory to target destination. fs . move ( destdir . path , root , error => { if ( error ) { // Cleanup temp dir. destdir . cleanup ( ) ; reject ( error ) ; } else { resolve ( ) ; } } ) ; } catch ( error ) { // Cleanup temp dir. destdir . cleanup ( ) ; reject ( error ) ; } } ) . on ( 'error' , error => { destdir . cleanup ( ) ; reject ( error ) ; } ) ; } ) ; } ) ; }