Skip to content

Commit

Permalink
remove octal literals. closes #28
Browse files Browse the repository at this point in the history
  • Loading branch information
thejoshwolfe committed Oct 27, 2016
1 parent 006d5fa commit 9e4b0f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ zipfile.outputStream.pipe(fs.createWriteStream("output.zip")).on("close", functi
// alternate apis for adding files:
zipfile.addReadStream(process.stdin, "stdin.txt", {
mtime: new Date(),
mode: 0100664, // -rw-rw-r--
mode: parseInt("0100664", 8), // -rw-rw-r--
});
zipfile.addBuffer(new Buffer("hello"), "hello.txt", {
mtime: new Date(),
mode: 0100664, // -rw-rw-r--
mode: parseInt("0100664", 8), // -rw-rw-r--
});
// call end() after all the files have been added
zipfile.end();
Expand Down Expand Up @@ -324,6 +324,8 @@ In order to create empty directories, use `addEmptyDirectory()`.

## Change History

* 2.4.2
* Remove octal literals to make yazl compatible with strict mode. [pull #28](https://github.com/thejoshwolfe/yazl/pull/28)
* 2.4.1
* Fix Mac Archive Utility compatibility issue. [issue #24](https://github.com/thejoshwolfe/yazl/issues/24)
* 2.4.0
Expand Down
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,9 @@ function validateMetadataPath(metadataPath, isDirectory) {
return metadataPath;
}

var defaultFileMode = parseInt("0100664", 8);
var defaultDirectoryMode = parseInt("040775", 8);

// this class is not part of the public API
function Entry(metadataPath, isDirectory, options) {
this.utf8FileName = new Buffer(metadataPath);
Expand All @@ -370,7 +373,7 @@ function Entry(metadataPath, isDirectory, options) {
if (options.mode != null) {
this.setFileAttributesMode(options.mode);
} else {
this.setFileAttributesMode(isDirectory ? 040775 : 0100664);
this.setFileAttributesMode(isDirectory ? defaultDirectoryMode : defaultFileMode);
}
if (isDirectory) {
this.crcAndFileSizeKnown = true;
Expand Down

0 comments on commit 9e4b0f2

Please sign in to comment.