nl_tokens: Helper function to copy a base64 - encoded zip file to a temporary location decompress it into temporary directory and return the name of that directory . Note that this makes heavy use of shell commands because : 1 ) Node 0 . 12 doesn t have many of the useful fs functions . 2 ) We know in which environment we re running .
pl_tokens: function unzipInTmpDir ( base64 ) { var mkTempCmd = "mktemp -d XXXXXXXX" ; return exec ( mkTempCmd ) . then ( function ( tmpDir1 ) { return new Promise ( function ( resolve , reject ) { var zipFile = path . join ( tmpDir1 , "action.zip" ) ; fs . writeFile ( zipFile , base64 , "base64" , function ( err ) { if ( err ) { reject ( "There was an error reading the action archive." ) ; } resolve ( zipFile ) ; } ) ; } ) ; } ) . then ( function ( zipFile ) { return exec ( mkTempCmd ) . then ( function ( tmpDir2 ) { return exec ( "unzip -qq " + zipFile + " -d " + tmpDir2 ) . then ( function ( <mask> ) { return path . resolve ( tmpDir2 ) ; } ) . catch ( function ( error ) { return Promise . reject ( "There was an error uncompressing the action archive." ) ; } ) ; } ) ; } ) ; }