Skip to content
This repository was archived by the owner on Apr 25, 2024. It is now read-only.

Commit 0dd012c

Browse files
pirannamafintosh
authored andcommitted
Added umask option for pack() function (#57)
* Strip symlinks linkname only for absolute paths * Replaced `const` keyword for `var` * Added `umask` option for `pack()` function
1 parent a5e4f5e commit 0dd012c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ exports.pack = function (cwd, opts) {
6767
var mapStream = opts.mapStream || echo
6868
var statNext = statAll(xfs, opts.dereference ? xfs.stat : xfs.lstat, cwd, ignore, opts.entries, opts.sort)
6969
var strict = opts.strict !== false
70+
var umask = typeof opts.umask === 'number' ? ~opts.umask : ~processUmask()
7071
var dmode = typeof opts.dmode === 'number' ? opts.dmode : 0
7172
var fmode = typeof opts.fmode === 'number' ? opts.fmode : 0
7273
var pack = opts.pack || tar.pack()
@@ -98,7 +99,7 @@ exports.pack = function (cwd, opts) {
9899

99100
var header = {
100101
name: normalize(filename),
101-
mode: stat.mode | (stat.isDirectory() ? dmode : fmode),
102+
mode: (stat.mode | (stat.isDirectory() ? dmode : fmode)) & umask,
102103
mtime: stat.mtime,
103104
size: stat.size,
104105
type: 'file',
@@ -216,7 +217,9 @@ exports.extract = function (cwd, opts) {
216217
var chown = link ? xfs.lchown : xfs.chown
217218

218219
if (!chmod) return cb()
219-
chmod(name, (header.mode | (header.type === 'directory' ? dmode : fmode)) & umask, function (err) {
220+
221+
var mode = (header.mode | (header.type === 'directory' ? dmode : fmode)) & umask
222+
chmod(name, mode, function (err) {
220223
if (err) return cb(err)
221224
if (!own) return cb()
222225
if (!chown) return cb()

0 commit comments

Comments
 (0)