Skip to content

Commit

Permalink
feat(file): Add support for file special bits on unix
Browse files Browse the repository at this point in the history
  • Loading branch information
wedgybo committed Aug 25, 2016
1 parent 37676c9 commit d31339c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,17 @@ Archiver.prototype._normalizeEntryData = function(data, stats) {

// 511 === 0777; 493 === 0755; 438 === 0666; 420 === 0644
if (typeof data.mode === 'number') {
data.mode &= 511;
if (win32) {
data.mode &= 511;
} else {
data.mode &= 4095
}
} else if (data.stats && data.mode === null) {
data.mode = data.stats.mode & 511;
if (win32) {
data.mode = data.stats.mode & 511;
} else {
data.mode = data.stats.mode & 4095;
}

// stat isn't reliable on windows; force 0755 for dir
if (win32 && isDir) {
Expand Down
7 changes: 7 additions & 0 deletions test/archiver.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ describe('archiver', function() {
var prefix2 = archive._normalizeEntryData({ name: 'entry.txt', prefix: '' });
assert.propertyVal(prefix2, 'name', 'entry.txt');
});

it('should support special bits on unix', function () {
if (!win32) {
var mode = archive._normalizeEntryData({ name: 'executable.sh', mode: fs.statSync('test/fixtures/executable.sh').mode });
assert.propertyVal(mode, 'mode', 511);
}
});
});
});

Expand Down

0 comments on commit d31339c

Please sign in to comment.