-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathdemo.js
35 lines (28 loc) · 865 Bytes
/
demo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var fs = require("fs");
var zip = require("./index");
//(function () {
// var archive = new zip();
//
// archive.add("hello.txt", new Buffer("Hello world", "utf8"));
//
// var buffer = archive.toBuffer();
// fs.writeFile("./test1.zip", buffer, function () {
// console.log("Finished");
// });
//})
(function () {
var zip = require("./index");
var archive = new zip();
archive.addFiles([
{ name: "test.txt", path: "./test/test.txt" }//,
//{ name: "images/sam.jpg", path: "./test/images.jpg" }
], function () {
var buff = archive.toBuffer();
fs.writeFile("./test_new.zip", buff, function () {
console.log("im finished");
});
}, function (err) {
console.log(err);
});
//archive.add("smile.txt", new Buffer("Smile!", "utf8"));
}())