Comparing version 6.0.5 to 6.1.0
@@ -7,3 +7,2 @@ 'use strict' | ||
const Pack = require('./pack.js') | ||
const fs = require('fs') | ||
const fsm = require('fs-minipass') | ||
@@ -13,3 +12,3 @@ const t = require('./list.js') | ||
const c = module.exports = (opt_, files, cb) => { | ||
module.exports = (opt_, files, cb) => { | ||
if (typeof files === 'function') | ||
@@ -43,3 +42,3 @@ cb = files | ||
const stream = new fsm.WriteStreamSync(opt.file, { | ||
mode: opt.mode || 0o666 | ||
mode: opt.mode || 0o666, | ||
}) | ||
@@ -53,3 +52,3 @@ p.pipe(stream) | ||
const stream = new fsm.WriteStream(opt.file, { | ||
mode: opt.mode || 0o666 | ||
mode: opt.mode || 0o666, | ||
}) | ||
@@ -71,3 +70,3 @@ p.pipe(stream) | ||
files.forEach(file => { | ||
if (file.charAt(0) === '@') | ||
if (file.charAt(0) === '@') { | ||
t({ | ||
@@ -77,5 +76,5 @@ file: path.resolve(p.cwd, file.substr(1)), | ||
noResume: true, | ||
onentry: entry => p.add(entry) | ||
onentry: entry => p.add(entry), | ||
}) | ||
else | ||
} else | ||
p.add(file) | ||
@@ -89,9 +88,9 @@ }) | ||
const file = files.shift() | ||
if (file.charAt(0) === '@') | ||
if (file.charAt(0) === '@') { | ||
return t({ | ||
file: path.resolve(p.cwd, file.substr(1)), | ||
noResume: true, | ||
onentry: entry => p.add(entry) | ||
onentry: entry => p.add(entry), | ||
}).then(_ => addFilesAsync(p, files)) | ||
else | ||
} else | ||
p.add(file) | ||
@@ -98,0 +97,0 @@ } |
@@ -10,3 +10,3 @@ 'use strict' | ||
const x = module.exports = (opt_, files, cb) => { | ||
module.exports = (opt_, files, cb) => { | ||
if (typeof opt_ === 'function') | ||
@@ -67,11 +67,9 @@ cb = opt_, files = null, opt_ = {} | ||
const file = opt.file | ||
let threw = true | ||
let fd | ||
const stat = fs.statSync(file) | ||
// This trades a zero-byte read() syscall for a stat | ||
// However, it will usually result in less memory allocation | ||
const readSize = opt.maxReadSize || 16*1024*1024 | ||
const readSize = opt.maxReadSize || 16 * 1024 * 1024 | ||
const stream = new fsm.ReadStreamSync(file, { | ||
readSize: readSize, | ||
size: stat.size | ||
size: stat.size, | ||
}) | ||
@@ -83,3 +81,3 @@ stream.pipe(u) | ||
const u = new Unpack(opt) | ||
const readSize = opt.maxReadSize || 16*1024*1024 | ||
const readSize = opt.maxReadSize || 16 * 1024 * 1024 | ||
@@ -99,3 +97,3 @@ const file = opt.file | ||
readSize: readSize, | ||
size: stat.size | ||
size: stat.size, | ||
}) | ||
@@ -110,8 +108,4 @@ stream.on('error', reject) | ||
const extractSync = opt => { | ||
return new Unpack.Sync(opt) | ||
} | ||
const extractSync = opt => new Unpack.Sync(opt) | ||
const extract = opt => { | ||
return new Unpack(opt) | ||
} | ||
const extract = opt => new Unpack(opt) |
@@ -98,8 +98,8 @@ 'use strict' | ||
let sum = 8 * 0x20 | ||
for (let i = off; i < off + 148; i++) { | ||
for (let i = off; i < off + 148; i++) | ||
sum += buf[i] | ||
} | ||
for (let i = off + 156; i < off + 512; i++) { | ||
for (let i = off + 156; i < off + 512; i++) | ||
sum += buf[i] | ||
} | ||
this.cksumValid = sum === this.cksum | ||
@@ -111,3 +111,3 @@ if (this.cksum === null && sum === 8 * 0x20) | ||
[SLURP] (ex, global) { | ||
for (let k in ex) { | ||
for (const k in ex) { | ||
// we slurp in everything except for the path attribute in | ||
@@ -162,8 +162,8 @@ // a global extended header, because that's weird. | ||
let sum = 8 * 0x20 | ||
for (let i = off; i < off + 148; i++) { | ||
for (let i = off; i < off + 148; i++) | ||
sum += buf[i] | ||
} | ||
for (let i = off + 156; i < off + 512; i++) { | ||
for (let i = off + 156; i < off + 512; i++) | ||
sum += buf[i] | ||
} | ||
this.cksum = sum | ||
@@ -177,3 +177,3 @@ encNumber(buf, off + 148, 8, this.cksum) | ||
set (data) { | ||
for (let i in data) { | ||
for (const i in data) { | ||
if (data[i] !== null && data[i] !== undefined) | ||
@@ -249,3 +249,3 @@ this[i] = data[i] | ||
buf[off] & 0x80 ? large.parse(buf.slice(off, off + size)) | ||
: decSmallNumber(buf, off, size) | ||
: decSmallNumber(buf, off, size) | ||
@@ -262,3 +262,3 @@ const nanNull = value => isNaN(value) ? null : value | ||
12: 0o77777777777, | ||
8 : 0o7777777 | ||
8: 0o7777777, | ||
} | ||
@@ -292,4 +292,4 @@ | ||
(buf.write(string + NULLS, off, size, 'utf8'), | ||
string.length !== Buffer.byteLength(string) || string.length > size) | ||
string.length !== Buffer.byteLength(string) || string.length > size) | ||
module.exports = Header |
@@ -24,7 +24,7 @@ 'use strict' | ||
['L', 'follow'], | ||
['h', 'follow'] | ||
['h', 'follow'], | ||
]) | ||
const parse = module.exports = opt => opt ? Object.keys(opt).map(k => [ | ||
argmap.has(k) ? argmap.get(k) : k, opt[k] | ||
module.exports = opt => opt ? Object.keys(opt).map(k => [ | ||
argmap.has(k) ? argmap.get(k) : k, opt[k], | ||
]).reduce((set, kv) => (set[kv[0]] = kv[1], set), Object.create(null)) : {} |
@@ -5,3 +5,3 @@ 'use strict' | ||
const encode = exports.encode = (num, buf) => { | ||
const encode = (num, buf) => { | ||
if (!Number.isSafeInteger(num)) | ||
@@ -22,3 +22,3 @@ // The number is so large that javascript cannot represent it with integer | ||
for (var i = buf.length; i > 1; i--) { | ||
buf[i-1] = num & 0xff | ||
buf[i - 1] = num & 0xff | ||
num = Math.floor(num / 0x100) | ||
@@ -36,8 +36,8 @@ } | ||
if (flipped) | ||
buf[i-1] = onesComp(byte) | ||
buf[i - 1] = onesComp(byte) | ||
else if (byte === 0) | ||
buf[i-1] = 0 | ||
buf[i - 1] = 0 | ||
else { | ||
flipped = true | ||
buf[i-1] = twosComp(byte) | ||
buf[i - 1] = twosComp(byte) | ||
} | ||
@@ -47,11 +47,8 @@ } | ||
const parse = exports.parse = (buf) => { | ||
var post = buf[buf.length - 1] | ||
var pre = buf[0] | ||
var value; | ||
if (pre === 0x80) | ||
value = pos(buf.slice(1, buf.length)) | ||
else if (pre === 0xff) | ||
value = twos(buf) | ||
else | ||
const parse = (buf) => { | ||
const pre = buf[0] | ||
const value = pre === 0x80 ? pos(buf.slice(1, buf.length)) | ||
: pre === 0xff ? twos(buf) | ||
: null | ||
if (value === null) | ||
throw Error('invalid base256 encoding') | ||
@@ -102,1 +99,6 @@ | ||
const twosComp = byte => ((0xff ^ byte) + 1) & 0xff | ||
module.exports = { | ||
encode, | ||
parse, | ||
} |
@@ -13,3 +13,3 @@ 'use strict' | ||
const t = module.exports = (opt_, files, cb) => { | ||
module.exports = (opt_, files, cb) => { | ||
if (typeof opt_ === 'function') | ||
@@ -83,6 +83,6 @@ cb = opt_, files = null, opt_ = {} | ||
const stat = fs.statSync(file) | ||
const readSize = opt.maxReadSize || 16*1024*1024 | ||
if (stat.size < readSize) { | ||
const readSize = opt.maxReadSize || 16 * 1024 * 1024 | ||
if (stat.size < readSize) | ||
p.end(fs.readFileSync(file)) | ||
} else { | ||
else { | ||
let pos = 0 | ||
@@ -92,3 +92,3 @@ const buf = Buffer.allocUnsafe(readSize) | ||
while (pos < stat.size) { | ||
let bytesRead = fs.readSync(fd, buf, 0, readSize, pos) | ||
const bytesRead = fs.readSync(fd, buf, 0, readSize, pos) | ||
pos += bytesRead | ||
@@ -101,4 +101,7 @@ p.write(buf.slice(0, bytesRead)) | ||
} finally { | ||
if (threw && fd) | ||
try { fs.closeSync(fd) } catch (er) {} | ||
if (threw && fd) { | ||
try { | ||
fs.closeSync(fd) | ||
} catch (er) {} | ||
} | ||
} | ||
@@ -109,3 +112,3 @@ } | ||
const parse = new Parser(opt) | ||
const readSize = opt.maxReadSize || 16*1024*1024 | ||
const readSize = opt.maxReadSize || 16 * 1024 * 1024 | ||
@@ -123,3 +126,3 @@ const file = opt.file | ||
readSize: readSize, | ||
size: stat.size | ||
size: stat.size, | ||
}) | ||
@@ -126,0 +129,0 @@ stream.on('error', reject) |
@@ -36,3 +36,3 @@ 'use strict' | ||
const mkdir = module.exports = (dir, opt, cb) => { | ||
module.exports = (dir, opt, cb) => { | ||
// if there's any overlap between mask and mode, | ||
@@ -48,3 +48,3 @@ // then we'll need an explicit chmod | ||
typeof gid === 'number' && | ||
( uid !== opt.processUid || gid !== opt.processGid ) | ||
(uid !== opt.processUid || gid !== opt.processGid) | ||
@@ -73,3 +73,3 @@ const preserve = opt.preserve | ||
if (dir === cwd) | ||
if (dir === cwd) { | ||
return fs.stat(dir, (er, st) => { | ||
@@ -80,2 +80,3 @@ if (er || !st.isDirectory()) | ||
}) | ||
} | ||
@@ -111,3 +112,3 @@ if (preserve) | ||
mkdir_(part, parts, mode, cache, unlink, cwd, created, cb) | ||
else if (unlink) | ||
else if (unlink) { | ||
fs.unlink(part, er => { | ||
@@ -118,3 +119,3 @@ if (er) | ||
}) | ||
else if (st.isSymbolicLink()) | ||
} else if (st.isSymbolicLink()) | ||
return cb(new SymlinkError(part, part + '/' + parts.join('/'))) | ||
@@ -130,3 +131,3 @@ else | ||
const mkdirSync = module.exports.sync = (dir, opt) => { | ||
module.exports.sync = (dir, opt) => { | ||
// if there's any overlap between mask and mode, | ||
@@ -142,3 +143,3 @@ // then we'll need an explicit chmod | ||
typeof gid === 'number' && | ||
( uid !== opt.processUid || gid !== opt.processGid ) | ||
(uid !== opt.processUid || gid !== opt.processGid) | ||
@@ -183,5 +184,4 @@ const preserve = opt.preserve | ||
for (let p = parts.shift(), part = cwd; | ||
p && (part += '/' + p); | ||
p = parts.shift()) { | ||
p && (part += '/' + p); | ||
p = parts.shift()) { | ||
if (cache.get(part)) | ||
@@ -188,0 +188,0 @@ continue |
@@ -10,5 +10,4 @@ 'use strict' | ||
// a file that is not readable/writable by the owner. | ||
if (portable) { | ||
mode = (mode | 0o600) &~0o22 | ||
} | ||
if (portable) | ||
mode = (mode | 0o600) & ~0o22 | ||
@@ -15,0 +14,0 @@ // if dirs are readable, then they should be listable |
@@ -100,3 +100,3 @@ 'use strict' | ||
this[QUEUE] = new Yallist | ||
this[QUEUE] = new Yallist() | ||
this[JOBS] = 0 | ||
@@ -213,4 +213,4 @@ this.jobs = +opt.jobs || 4 | ||
for (let w = this[QUEUE].head; | ||
w !== null && this[JOBS] < this.jobs; | ||
w = w.next) { | ||
w !== null && this[JOBS] < this.jobs; | ||
w = w.next) { | ||
this[PROCESSJOB](w.value) | ||
@@ -302,3 +302,3 @@ if (w.value.ignore) { | ||
noMtime: this.noMtime, | ||
mtime: this.mtime | ||
mtime: this.mtime, | ||
} | ||
@@ -327,3 +327,3 @@ } | ||
if (job.readdir) | ||
if (job.readdir) { | ||
job.readdir.forEach(entry => { | ||
@@ -337,2 +337,3 @@ const p = this.prefix ? | ||
}) | ||
} | ||
@@ -342,3 +343,3 @@ const source = job.entry | ||
if (zip) | ||
if (zip) { | ||
source.on('data', chunk => { | ||
@@ -348,3 +349,3 @@ if (!zip.write(chunk)) | ||
}) | ||
else | ||
} else { | ||
source.on('data', chunk => { | ||
@@ -354,2 +355,3 @@ if (!super.write(chunk)) | ||
}) | ||
} | ||
} | ||
@@ -388,3 +390,3 @@ | ||
if (job.readdir) | ||
if (job.readdir) { | ||
job.readdir.forEach(entry => { | ||
@@ -398,11 +400,13 @@ const p = this.prefix ? | ||
}) | ||
} | ||
if (zip) | ||
if (zip) { | ||
source.on('data', chunk => { | ||
zip.write(chunk) | ||
}) | ||
else | ||
} else { | ||
source.on('data', chunk => { | ||
super[WRITE](chunk) | ||
}) | ||
} | ||
} | ||
@@ -409,0 +413,0 @@ } |
@@ -24,3 +24,2 @@ 'use strict' | ||
const warner = require('./warn-mixin.js') | ||
const path = require('path') | ||
const Header = require('./header.js') | ||
@@ -89,3 +88,3 @@ const EE = require('events') | ||
this.on(DONE, opt.ondone) | ||
else | ||
else { | ||
this.on(DONE, _ => { | ||
@@ -97,2 +96,3 @@ this.emit('prefinish') | ||
}) | ||
} | ||
@@ -172,5 +172,4 @@ this.strict = !!opt.strict | ||
entry.on('end', onend) | ||
} else { | ||
} else | ||
this[SAW_VALID_ENTRY] = true | ||
} | ||
} | ||
@@ -256,3 +255,3 @@ | ||
re.once('drain', _ => this.emit('drain')) | ||
} | ||
} | ||
} | ||
@@ -360,3 +359,3 @@ | ||
this[WRITING] = true | ||
const ret = this[UNZIP][ended ? 'end' : 'write' ](chunk) | ||
const ret = this[UNZIP][ended ? 'end' : 'write'](chunk) | ||
this[WRITING] = false | ||
@@ -424,5 +423,4 @@ return ret | ||
this[CONSUMECHUNKSUB](c) | ||
} else { | ||
} else | ||
this[CONSUMECHUNKSUB](chunk) | ||
} | ||
@@ -448,3 +446,3 @@ while (this[BUFFER] && | ||
let position = 0 | ||
let length = chunk.length | ||
const length = chunk.length | ||
while (position + 512 <= length && !this[ABORTED] && !this[SAW_EOF]) { | ||
@@ -451,0 +449,0 @@ switch (this[STATE]) { |
@@ -23,4 +23,4 @@ // A path exclusive reservation system | ||
const getDirs = path => | ||
join(path).split(/[\\\/]/).slice(0, -1).reduce((set, path) => | ||
set.length ? set.concat(join(set[set.length-1], path)) : [path], []) | ||
join(path).split(/[\\/]/).slice(0, -1).reduce((set, path) => | ||
set.length ? set.concat(join(set[set.length - 1], path)) : [path], []) | ||
@@ -84,5 +84,5 @@ // functions currently running | ||
assert(q[0] instanceof Set) | ||
if (q[0].size === 1 && q.length === 1) { | ||
if (q[0].size === 1 && q.length === 1) | ||
queues.delete(dir) | ||
} else if (q[0].size === 1) { | ||
else if (q[0].size === 1) { | ||
q.shift() | ||
@@ -117,4 +117,4 @@ | ||
queues.set(dir, [new Set([fn])]) | ||
else if (q[q.length-1] instanceof Set) | ||
q[q.length-1].add(fn) | ||
else if (q[q.length - 1] instanceof Set) | ||
q[q.length - 1].add(fn) | ||
else | ||
@@ -121,0 +121,0 @@ q.push(new Set([fn])) |
@@ -37,5 +37,4 @@ 'use strict' | ||
// 0-fill the header section, it might not hit every field | ||
for (let i = 0; i < 512; i++) { | ||
for (let i = 0; i < 512; i++) | ||
buf[i] = 0 | ||
} | ||
@@ -59,3 +58,3 @@ new Header({ | ||
atime: this.atime || null, | ||
ctime: this.ctime || null | ||
ctime: this.ctime || null, | ||
}).encode(buf) | ||
@@ -66,5 +65,4 @@ | ||
// null pad after the body | ||
for (let i = bodyLen + 512; i < buf.length; i++) { | ||
for (let i = bodyLen + 512; i < buf.length; i++) | ||
buf[i] = 0 | ||
} | ||
@@ -101,3 +99,3 @@ return buf | ||
(field === 'dev' || field === 'ino' || field === 'nlink' | ||
? 'SCHILY.' : '') + | ||
? 'SCHILY.' : '') + | ||
field + '=' + v + '\n' | ||
@@ -143,3 +141,3 @@ const byteLen = Buffer.byteLength(s) | ||
set[k] = /^([A-Z]+\.)?([mac]|birth|creation)time$/.test(k) | ||
? new Date(v * 1000) | ||
? new Date(v * 1000) | ||
: /^[0-9]+$/.test(v) ? +v | ||
@@ -146,0 +144,0 @@ : v |
'use strict' | ||
const types = require('./types.js') | ||
const MiniPass = require('minipass') | ||
@@ -66,4 +65,6 @@ | ||
if (ex) this[SLURP](ex) | ||
if (gex) this[SLURP](gex, true) | ||
if (ex) | ||
this[SLURP](ex) | ||
if (gex) | ||
this[SLURP](gex, true) | ||
} | ||
@@ -91,3 +92,3 @@ | ||
[SLURP] (ex, global) { | ||
for (let k in ex) { | ||
for (const k in ex) { | ||
// we slurp in everything except for the path attribute in | ||
@@ -94,0 +95,0 @@ // a global extended header, because that's weird. |
@@ -6,3 +6,2 @@ 'use strict' | ||
const Pack = require('./pack.js') | ||
const Parse = require('./parse.js') | ||
const fs = require('fs') | ||
@@ -21,3 +20,3 @@ const fsm = require('fs-minipass') | ||
const r = module.exports = (opt_, files, cb) => { | ||
module.exports = (opt_, files, cb) => { | ||
const opt = hlo(opt_) | ||
@@ -73,6 +72,6 @@ | ||
let h = new Header(headBuf) | ||
const h = new Header(headBuf) | ||
if (!h.cksumValid) | ||
break | ||
let entryBlockSize = 512 * Math.ceil(h.size / 512) | ||
const entryBlockSize = 512 * Math.ceil(h.size / 512) | ||
if (position + entryBlockSize + 512 > st.size) | ||
@@ -90,4 +89,7 @@ break | ||
} finally { | ||
if (threw) | ||
try { fs.closeSync(fd) } catch (er) {} | ||
if (threw) { | ||
try { | ||
fs.closeSync(fd) | ||
} catch (er) {} | ||
} | ||
} | ||
@@ -99,3 +101,3 @@ } | ||
fd: fd, | ||
start: position | ||
start: position, | ||
}) | ||
@@ -128,3 +130,3 @@ p.pipe(stream) | ||
bufPos += bytes | ||
if (bufPos < 512 && bytes) | ||
if (bufPos < 512 && bytes) { | ||
return fs.read( | ||
@@ -134,2 +136,3 @@ fd, headBuf, bufPos, headBuf.length - bufPos, | ||
) | ||
} | ||
@@ -183,3 +186,3 @@ if (position === 0 && headBuf[0] === 0x1f && headBuf[1] === 0x8b) | ||
fd: fd, | ||
start: position | ||
start: position, | ||
}) | ||
@@ -201,3 +204,3 @@ p.pipe(stream) | ||
files.forEach(file => { | ||
if (file.charAt(0) === '@') | ||
if (file.charAt(0) === '@') { | ||
t({ | ||
@@ -207,5 +210,5 @@ file: path.resolve(p.cwd, file.substr(1)), | ||
noResume: true, | ||
onentry: entry => p.add(entry) | ||
onentry: entry => p.add(entry), | ||
}) | ||
else | ||
} else | ||
p.add(file) | ||
@@ -219,9 +222,9 @@ }) | ||
const file = files.shift() | ||
if (file.charAt(0) === '@') | ||
if (file.charAt(0) === '@') { | ||
return t({ | ||
file: path.resolve(p.cwd, file.substr(1)), | ||
noResume: true, | ||
onentry: entry => p.add(entry) | ||
onentry: entry => p.add(entry), | ||
}).then(_ => addFilesAsync(p, files)) | ||
else | ||
} else | ||
p.add(file) | ||
@@ -228,0 +231,0 @@ } |
@@ -40,3 +40,3 @@ 'use strict' | ||
// like x | ||
['X', 'OldExtendedHeader'] | ||
['X', 'OldExtendedHeader'], | ||
]) | ||
@@ -43,0 +43,0 @@ |
@@ -10,3 +10,2 @@ 'use strict' | ||
const assert = require('assert') | ||
const EE = require('events').EventEmitter | ||
const Parser = require('./parse.js') | ||
@@ -17,3 +16,2 @@ const fs = require('fs') | ||
const mkdir = require('./mkdir.js') | ||
const mkdirSync = mkdir.sync | ||
const wc = require('./winchars.js') | ||
@@ -33,3 +31,2 @@ const pathReservations = require('./path-reservations.js') | ||
const UNSUPPORTED = Symbol('unsupported') | ||
const UNKNOWN = Symbol('unknown') | ||
const CHECKPATH = Symbol('checkPath') | ||
@@ -127,5 +124,6 @@ const MKDIR = Symbol('mkdir') | ||
throw new TypeError('cannot set owner without number uid and gid') | ||
if (opt.preserveOwner) | ||
if (opt.preserveOwner) { | ||
throw new TypeError( | ||
'cannot preserve owner in archive and also set owner explicitly') | ||
} | ||
this.uid = opt.uid | ||
@@ -178,7 +176,10 @@ this.gid = opt.gid | ||
this.strip = +opt.strip || 0 | ||
this.processUmask = process.umask() | ||
// if we're not chmodding, then we don't need the process umask | ||
this.processUmask = opt.noChmod ? 0 : process.umask() | ||
this.umask = typeof opt.umask === 'number' ? opt.umask : this.processUmask | ||
// default mode for dirs created as parents | ||
this.dmode = opt.dmode || (0o0777 & (~this.umask)) | ||
this.fmode = opt.fmode || (0o0666 & (~this.umask)) | ||
this.on('entry', entry => this[ONENTRY](entry)) | ||
@@ -279,2 +280,3 @@ } | ||
case 'FIFO': | ||
default: | ||
return this[UNSUPPORTED](entry) | ||
@@ -308,3 +310,4 @@ } | ||
cwd: this.cwd, | ||
mode: mode | ||
mode: mode, | ||
noChmod: this.noChmod, | ||
}, cb) | ||
@@ -318,7 +321,7 @@ } | ||
this.preserveOwner && | ||
( typeof entry.uid === 'number' && entry.uid !== this.processUid || | ||
typeof entry.gid === 'number' && entry.gid !== this.processGid ) | ||
(typeof entry.uid === 'number' && entry.uid !== this.processUid || | ||
typeof entry.gid === 'number' && entry.gid !== this.processGid) | ||
|| | ||
( typeof this.uid === 'number' && this.uid !== this.processUid || | ||
typeof this.gid === 'number' && this.gid !== this.processGid ) | ||
(typeof this.uid === 'number' && this.uid !== this.processUid || | ||
typeof this.gid === 'number' && this.gid !== this.processGid) | ||
} | ||
@@ -339,3 +342,3 @@ | ||
mode: mode, | ||
autoClose: false | ||
autoClose: false, | ||
}) | ||
@@ -472,2 +475,3 @@ stream.on('error', er => this[ONERROR](er, entry)) | ||
} | ||
[CHECKFS2] (entry, done) { | ||
@@ -483,12 +487,13 @@ this[MKDIR](path.dirname(entry.absolute), this.dmode, er => { | ||
done() | ||
} else if (er || this[ISREUSABLE](entry, st)) { | ||
} else if (er || this[ISREUSABLE](entry, st)) | ||
this[MAKEFS](null, entry, done) | ||
} | ||
else if (st.isDirectory()) { | ||
if (entry.type === 'Directory') { | ||
if (!entry.mode || (st.mode & 0o7777) === entry.mode) | ||
if (!this.noChmod && (!entry.mode || (st.mode & 0o7777) === entry.mode)) | ||
this[MAKEFS](null, entry, done) | ||
else | ||
else { | ||
fs.chmod(entry.absolute, entry.mode, | ||
er => this[MAKEFS](er, entry, done)) | ||
} | ||
} else | ||
@@ -537,6 +542,2 @@ fs.rmdir(entry.absolute, er => this[MAKEFS](er, entry, done)) | ||
class UnpackSync extends Unpack { | ||
constructor (opt) { | ||
super(opt) | ||
} | ||
[CHECKFS] (entry) { | ||
@@ -556,3 +557,3 @@ const er = this[MKDIR](path.dirname(entry.absolute), this.dmode, neverCalled) | ||
if (entry.type === 'Directory') { | ||
if (entry.mode && (st.mode & 0o7777) !== entry.mode) | ||
if (!this.noChmod && entry.mode && (st.mode & 0o7777) !== entry.mode) | ||
fs.chmodSync(entry.absolute, entry.mode) | ||
@@ -587,3 +588,2 @@ } else | ||
let stream | ||
let fd | ||
@@ -676,3 +676,3 @@ try { | ||
cwd: this.cwd, | ||
mode: mode | ||
mode: mode, | ||
}) | ||
@@ -679,0 +679,0 @@ } catch (er) { |
@@ -9,3 +9,3 @@ 'use strict' | ||
const u = module.exports = (opt_, files, cb) => { | ||
module.exports = (opt_, files, cb) => { | ||
const opt = hlo(opt_) | ||
@@ -12,0 +12,0 @@ |
@@ -16,7 +16,7 @@ 'use strict' | ||
this.emit('warn', data.tarCode, message, data) | ||
} else if (message instanceof Error) { | ||
} else if (message instanceof Error) | ||
this.emit('error', Object.assign(message, data)) | ||
} else | ||
else | ||
this.emit('error', Object.assign(new Error(`${code}: ${message}`), data)) | ||
} | ||
} |
@@ -11,3 +11,3 @@ 'use strict' | ||
'?', | ||
':' | ||
':', | ||
] | ||
@@ -23,3 +23,3 @@ | ||
encode: s => raw.reduce((s, c) => s.split(c).join(toWin.get(c)), s), | ||
decode: s => win.reduce((s, c) => s.split(c).join(toRaw.get(c)), s) | ||
decode: s => win.reduce((s, c) => s.split(c).join(toRaw.get(c)), s), | ||
} |
@@ -5,7 +5,5 @@ 'use strict' | ||
const Header = require('./header.js') | ||
const ReadEntry = require('./read-entry.js') | ||
const fs = require('fs') | ||
const path = require('path') | ||
const types = require('./types.js') | ||
const maxReadSize = 16 * 1024 * 1024 | ||
@@ -138,8 +136,8 @@ const PROCESS = Symbol('process') | ||
uname: this.portable ? null : | ||
this.stat.uid === this.myuid ? this.myuser : '', | ||
this.stat.uid === this.myuid ? this.myuser : '', | ||
atime: this.portable ? null : this.stat.atime, | ||
ctime: this.portable ? null : this.stat.ctime | ||
ctime: this.portable ? null : this.stat.ctime, | ||
}) | ||
if (this.header.encode() && !this.noPax) | ||
if (this.header.encode() && !this.noPax) { | ||
this.write(new Pax({ | ||
@@ -157,4 +155,5 @@ atime: this.portable ? null : this.header.atime, | ||
ino: this.portable ? null : this.stat.ino, | ||
nlink: this.portable ? null : this.stat.nlink | ||
nlink: this.portable ? null : this.stat.nlink, | ||
}).encode()) | ||
} | ||
this.write(this.header.block) | ||
@@ -262,4 +261,4 @@ } | ||
buf[i + offset] = 0 | ||
bytesRead ++ | ||
remain ++ | ||
bytesRead++ | ||
remain++ | ||
} | ||
@@ -293,6 +292,2 @@ } | ||
class WriteEntrySync extends WriteEntry { | ||
constructor (path, opt) { | ||
super(path, opt) | ||
} | ||
[LSTAT] () { | ||
@@ -319,4 +314,7 @@ this[ONLSTAT](fs.lstatSync(this.absolute)) | ||
// this point we already have an error, don't need another one | ||
if (threw) | ||
try { this[CLOSE](fd, () => {}) } catch (er) {} | ||
if (threw) { | ||
try { | ||
this[CLOSE](fd, () => {}) | ||
} catch (er) {} | ||
} | ||
} | ||
@@ -384,3 +382,3 @@ } | ||
atime: this.portable ? null : this.atime, | ||
ctime: this.portable ? null : this.ctime | ||
ctime: this.portable ? null : this.ctime, | ||
}) | ||
@@ -395,3 +393,3 @@ | ||
if (this.header.encode() && !this.noPax) | ||
if (this.header.encode() && !this.noPax) { | ||
super.write(new Pax({ | ||
@@ -409,4 +407,5 @@ atime: this.portable ? null : this.atime, | ||
ino: this.portable ? null : this.readEntry.ino, | ||
nlink: this.portable ? null : this.readEntry.nlink | ||
nlink: this.portable ? null : this.readEntry.nlink, | ||
}).encode()) | ||
} | ||
@@ -413,0 +412,0 @@ super.write(this.header.block) |
@@ -5,3 +5,3 @@ { | ||
"description": "tar for node", | ||
"version": "6.0.5", | ||
"version": "6.1.0", | ||
"repository": { | ||
@@ -13,2 +13,6 @@ "type": "git", | ||
"test": "tap", | ||
"posttest": "npm run lint", | ||
"eslint": "eslint", | ||
"lint": "npm run eslint -- test lib", | ||
"lintfix": "npm run lint -- --fix", | ||
"preversion": "npm test", | ||
@@ -31,2 +35,7 @@ "postversion": "npm publish", | ||
"end-of-stream": "^1.4.3", | ||
"eslint": "^7.17.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-promise": "^4.2.1", | ||
"eslint-plugin-standard": "^5.0.0", | ||
"events-to-array": "^1.1.2", | ||
@@ -33,0 +42,0 @@ "mutate-fs": "^2.1.1", |
# node-tar | ||
[![Build Status](https://travis-ci.org/npm/node-tar.svg?branch=master)](https://travis-ci.org/npm/node-tar) | ||
[Fast](./benchmarks) and full-featured Tar for Node.js | ||
@@ -307,3 +305,2 @@ | ||
The following options are mostly internal, but can be modified in some | ||
@@ -402,2 +399,9 @@ advanced use cases, such as re-using caches between runs. | ||
that passes the filter. | ||
- `onwarn` A function that will get called with `(code, message, data)` for | ||
any warnings encountered. (See "Warnings and Errors") | ||
- `noChmod` Set to true to omit calling `fs.chmod()` to ensure that the | ||
extracted file matches the entry mode. This also suppresses the call to | ||
`process.umask()` to determine the default umask value, since tar will | ||
extract with whatever mode is provided, and let the process `umask` apply | ||
normally. | ||
@@ -458,2 +462,4 @@ The following options are mostly internal, but can be modified in some | ||
complete until the entry data is consumed. | ||
- `onwarn` A function that will get called with `(code, message, data)` for | ||
any warnings encountered. (See "Warnings and Errors") | ||
@@ -716,2 +722,7 @@ ### tar.u(options, fileList, callback) [alias: tar.update] | ||
any warnings encountered. (See "Warnings and Errors") | ||
- `noChmod` Set to true to omit calling `fs.chmod()` to ensure that the | ||
extracted file matches the entry mode. This also suppresses the call to | ||
`process.umask()` to determine the default umask value, since tar will | ||
extract with whatever mode is provided, and let the process `umask` apply | ||
normally. | ||
@@ -718,0 +729,0 @@ ### class tar.Unpack.Sync |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
150295
1043
15
13
3226
1