vendor/nexe/exe.js
function unzipNodeTarball(next) {
        var onError = function(err) {
          console.log(err.stack);
          _log('error', 'failed to extract the node source');
          process.exit(1);
        };

        if (isWin) {
          _log('extracting the node source [node-tar.gz]');

          // tar-stream method w/ gunzip-maybe
          var read = fs.createReadStream(nodeFilePath);
          var extract = tarstream.extract();
          var basedir = nodeFileDir;

          if (!fs.existsSync(nodeFileDir)) {
            fs.mkdirSync(nodeFileDir);
          }

          extract.on('entry', function(header, stream, callback) {
            // header is the tar header
            // stream is the content body (might be an empty stream)
            // call next when you are done with this entry

            var absolutepath = path.join(basedir, header.name);
            if (header.type === 'directory') {
              // handle directories.
              // console.log('dir:', header.name);
              fs.mkdirSync(absolutepath);
              return callback();
            } else if (header.type === 'file') {
              // handle files
              // console.log('file:', header.name);
            } else {
              console.log(header.type + ':', header.name);
              _log('warn', 'unhandled type in tar extraction, skipping');
              return callback();
            }

            var write = fs.createWriteStream(absolutepath);

            stream.pipe(write);

            write.on('close', function() {
              return callback();
            });

            stream.on('error', function(err) {
              return onError(err);
            });

            write.on('error', function(err) {
              return onError(err);
            });

            stream.resume(); // just auto drain the stream
          });

          extract.on('finish', function() {
            _log('extraction finished');
            return next();
          });

          read.pipe(gunzip()).pipe(extract);
        } else {
          _log('extracting the node source [native tar]');

          var cmd = ['tar', '-xf', nodeFilePath, '-C', nodeFileDir];
          _log(cmd.join(' '));

          var tar = spawn(cmd.shift(), cmd);
          tar.stdout.pipe(process.stdout);
          tar.stderr.pipe(process.stderr);

          tar.on('close', function() {
            return next();
          });
          tar.on('error', onError);
        }
      }
function unzipNodeTarball(next) {
        var onError = function(err) {
          console.log(err.stack);
          _log('error', 'failed to extract the node source');
          process.exit(1);
        };

        if (isWin) {
          _log('extracting the node source [node-tar.gz]');

          // tar-stream method w/ gunzip-maybe
          var read = fs.createReadStream(nodeFilePath);
          var extract = tarstream.extract();
          var basedir = nodeFileDir;

          if (!fs.existsSync(nodeFileDir)) {
            fs.mkdirSync(nodeFileDir);
          }

          extract.on('entry', function(header, stream, callback) {
            // header is the tar header
            // stream is the content body (might be an empty stream)
            // call next when you are done with this entry

            var absolutepath = path.join(basedir, header.name);
            if (header.type === 'directory') {
              // handle directories.
              // console.log('dir:', header.name);
              fs.mkdirSync(absolutepath);
              return callback();
            } else if (header.type === 'file') {
              // handle files
              // console.log('file:', header.name);
            } else {
              console.log(header.type + ':', header.name);
              _log('warn', 'unhandled type in tar extraction, skipping');
              return callback();
            }

            var write = fs.createWriteStream(absolutepath);

            stream.pipe(write);

            write.on('close', function() {
              return callback();
            });

            stream.on('error', function(err) {
              return onError(err);
            });

            write.on('error', function(err) {
              return onError(err);
            });

            stream.resume(); // just auto drain the stream
          });

          extract.on('finish', function() {
            _log('extraction finished');
            return next();
          });

          read.pipe(gunzip()).pipe(extract);
        } else {
          _log('extracting the node source [native tar]');

          var cmd = ['tar', '-xf', nodeFilePath, '-C', nodeFileDir];
          _log(cmd.join(' '));

          var tar = spawn(cmd.shift(), cmd);
          tar.stdout.pipe(process.stdout);
          tar.stderr.pipe(process.stderr);

          tar.on('close', function() {
            return next();
          });
          tar.on('error', onError);
        }
      }
function unzipNodeTarball ( next ) { var onError = function ( err ) { console . log ( err . stack ) ; _log ( 'error' , 'failed to extract the node source' ) ; process . exit ( 1 ) ; } ; if ( isWin ) { _log ( 'extracting the node source [node-tar.gz]' ) ; // tar-stream method w/ gunzip-maybe var read = fs . createReadStream ( nodeFilePath ) ; var extract = tarstream . extract ( ) ; var basedir = nodeFileDir ; if ( ! fs . existsSync ( nodeFileDir ) ) { fs . mkdirSync ( nodeFileDir ) ; } extract . on ( 'entry' , function ( header , stream , callback ) { // header is the tar header // stream is the content body (might be an empty stream) // call next when you are done with this entry var absolutepath = path . join ( basedir , header . name ) ; if ( header . type === 'directory' ) { // handle directories. // console.log('dir:', header.name); fs . mkdirSync ( absolutepath ) ; return callback ( ) ; } else if ( header . type === 'file' ) { // handle files // console.log('file:', header.name); } else { console . log ( header . type + ':' , header . name ) ; _log ( 'warn' , 'unhandled type in tar extraction, skipping' ) ; return callback ( ) ; } var write = fs . createWriteStream ( absolutepath ) ; stream . pipe ( write ) ; write . on ( 'close' , function ( ) { return callback ( ) ; } ) ; stream . on ( 'error' , function ( err ) { return onError ( err ) ; } ) ; write . on ( 'error' , function ( err ) { return onError ( err ) ; } ) ; stream . resume ( ) ; // just auto drain the stream } ) ; extract . on ( 'finish' , function ( ) { _log ( 'extraction finished' ) ; return next ( ) ; } ) ; read . pipe ( gunzip ( ) ) . pipe ( extract ) ; } else { _log ( 'extracting the node source [native tar]' ) ; var cmd = [ 'tar' , '-xf' , nodeFilePath , '-C' , nodeFileDir ] ; _log ( cmd . join ( ' ' ) ) ; var tar = spawn ( cmd . shift ( ) , cmd ) ; tar . stdout . pipe ( process . stdout ) ; tar . stderr . pipe ( process . stderr ) ; tar . on ( 'close' , function ( ) { return next ( ) ; } ) ; tar . on ( 'error' , onError ) ; } }
unzip in the same directory
unzip in the same directory