index.js
function packFiles (tempPath, files, callback) {
  var self = this

  async.eachSeries(files, function (crtFile, done) {
    var filePath = path.resolve(crtFile.src[0])
    debug('adding %s', filePath)
    async.waterfall([
      fs.stat.bind(fs, filePath),
      function (stats, wtfDone) {
        if (stats.isDirectory()) {
          addParentDirs(self.data, crtFile.dest, self.dirs, done)
        } else {
          async.waterfall([
            fs.readFile.bind(fs, filePath),
            function writeFileToTarball (data, wtf2Done) {
              self.data.entry({
                name: '.' + crtFile.dest,
                size: stats.size
              }, data, function (err) {
                wtf2Done(err, data)
              })
            },

            function processFile (fileData, wtf2Done) {
              self.pkgSize += stats.size

              self.filesMd5.push({
                path: crtFile.dest,
                md5: crypto.createHash('md5').update(fileData).digest('hex')
              })

              wtf2Done()
            }
          ], wtfDone)
        }
      }
    ], done)
  }, function (err) {
    if (err) {
      debug('there was a problem adding files to the .deb package: ', err)
      callback(err)
    } else {
      debug('successfully added files to .deb package')

      var file = fs.createWriteStream(path.join(tempPath, 'data.tar.gz'))
      file.on('finish', callback)

      var compress = zlib.createGzip()
      compress.pipe(file)

      self.data.pipe(compress)
      self.data.finalize()
    }
  })
}
function packFiles (tempPath, files, callback) {
  var self = this

  async.eachSeries(files, function (crtFile, done) {
    var filePath = path.resolve(crtFile.src[0])
    debug('adding %s', filePath)
    async.waterfall([
      fs.stat.bind(fs, filePath),
      function (stats, wtfDone) {
        if (stats.isDirectory()) {
          addParentDirs(self.data, crtFile.dest, self.dirs, done)
        } else {
          async.waterfall([
            fs.readFile.bind(fs, filePath),
            function writeFileToTarball (data, wtf2Done) {
              self.data.entry({
                name: '.' + crtFile.dest,
                size: stats.size
              }, data, function (err) {
                wtf2Done(err, data)
              })
            },

            function processFile (fileData, wtf2Done) {
              self.pkgSize += stats.size

              self.filesMd5.push({
                path: crtFile.dest,
                md5: crypto.createHash('md5').update(fileData).digest('hex')
              })

              wtf2Done()
            }
          ], wtfDone)
        }
      }
    ], done)
  }, function (err) {
    if (err) {
      debug('there was a problem adding files to the .deb package: ', err)
      callback(err)
    } else {
      debug('successfully added files to .deb package')

      var file = fs.createWriteStream(path.join(tempPath, 'data.tar.gz'))
      file.on('finish', callback)

      var compress = zlib.createGzip()
      compress.pipe(file)

      self.data.pipe(compress)
      self.data.finalize()
    }
  })
}
function packFiles ( tempPath , files , callback ) { var self = this async . eachSeries ( files , function ( crtFile , done ) { var filePath = path . resolve ( crtFile . src [ 0 ] ) debug ( 'adding %s' , filePath ) async . waterfall ( [ fs . stat . bind ( fs , filePath ) , function ( stats , wtfDone ) { if ( stats . isDirectory ( ) ) { addParentDirs ( self . data , crtFile . dest , self . dirs , done ) } else { async . waterfall ( [ fs . readFile . bind ( fs , filePath ) , function writeFileToTarball ( data , wtf2Done ) { self . data . entry ( { name : '.' + crtFile . dest , size : stats . size } , data , function ( err ) { wtf2Done ( err , data ) } ) } , function processFile ( fileData , wtf2Done ) { self . pkgSize += stats . size self . filesMd5 . push ( { path : crtFile . dest , md5 : crypto . createHash ( 'md5' ) . update ( fileData ) . digest ( 'hex' ) } ) wtf2Done ( ) } ] , wtfDone ) } } ] , done ) } , function ( err ) { if ( err ) { debug ( 'there was a problem adding files to the .deb package: ' , err ) callback ( err ) } else { debug ( 'successfully added files to .deb package' ) var file = fs . createWriteStream ( path . join ( tempPath , 'data.tar.gz' ) ) file . on ( 'finish' , callback ) var compress = zlib . createGzip ( ) compress . pipe ( file ) self . data . pipe ( compress ) self . data . finalize ( ) } } ) }
Add files to the .deb package.

@param files - an object with the following format {'path/to/source/dir': 'path/to/target/dir'} (e.g. {'../../src/lib': '/srv/productName/lib'})
Add files to the . deb package .