@yaws/zip-dir

1.3.4 • Public • Published

zip-dir

Build status Git tag NPM version Code style

Zip a directory.

Installation

$ npm install @yaws/zip-dir

Usage

var zipDir = require('@yaws/zip-dir')
var co = require('co')
var hash = require('hasha')

co(function * () {
  var code = yield zipDir('./')
  var hash = hasha(code, {encoding: 'base64', alrogirthm: 'sha256'})
  s3.putObject({Bucket: 'code', Key: hash, Body: code})
})

// or

co(function * () {
  var code = yield zipDir(content)
  var hash = hasha(code, {encoding: 'base64', alrogirthm: 'sha256'})
  s3.putObject({Bucket: 'code', Key: hash, Body: code})
})

function content (zip) {
  zip.directory('./')
  zip.append('{"USER": "josh"}', '.env.json')
}

API

zipDir(src)

  • src {String} - Path to the directory to zip.
  • src {Function} - The function defines the sources using the zip api that is passed to it. The functions signature is src(zip). zip has three methods:
    • directory(path, dest)
    • file(path, opts|name)
    • append(src, opts|name)

Returns: a promise for a buffer of the zipped contents

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @yaws/zip-dir

Weekly Downloads

1

Version

1.3.4

License

MIT

Last publish

Collaborators

  • yaws