@yaws/zip-dir
v1.3.4
Published
Zip a directory.
Downloads
8
Readme
zip-dir
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 issrc(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