This commit is contained in:
2026-08-14 16:03:47 +01:00
parent fd53e3f4fb
commit dfdc3b2840
2463 changed files with 186456 additions and 111315 deletions
+14 -15
View File
@@ -4,11 +4,11 @@ import path from 'path';
import { Header } from './header.js';
import { modeFix } from './mode-fix.js';
import { normalizeWindowsPath } from './normalize-windows-path.js';
import { dealias, } from './options.js';
import { dealias } from './options.js';
import { Pax } from './pax.js';
import { stripAbsolutePath } from './strip-absolute-path.js';
import { stripTrailingSlashes } from './strip-trailing-slashes.js';
import { warnMethod, } from './warn-method.js';
import { warnMethod } from './warn-method.js';
import * as winchars from './winchars.js';
const prefixPath = (path, prefix) => {
if (!prefix) {
@@ -83,8 +83,7 @@ export class WriteEntry extends Minipass {
this.noPax = !!opt.noPax;
this.noMtime = !!opt.noMtime;
this.mtime = opt.mtime;
this.prefix =
opt.prefix ? normalizeWindowsPath(opt.prefix) : undefined;
this.prefix = opt.prefix ? normalizeWindowsPath(opt.prefix) : undefined;
this.onWriteEntry = opt.onWriteEntry;
if (typeof opt.onwarn === 'function') {
this.on('warn', opt.onwarn);
@@ -101,8 +100,8 @@ export class WriteEntry extends Minipass {
if (this.win32) {
// force the \ to / normalization, since we might not *actually*
// be on windows, but want \ to be considered a path separator.
this.path = winchars.decode(this.path.replace(/\\/g, '/'));
p = p.replace(/\\/g, '/');
this.path = winchars.decode(this.path.replaceAll(/\\/g, '/'));
p = p.replaceAll(/\\/g, '/');
}
this.absolute = normalizeWindowsPath(opt.absolute || path.resolve(this.cwd, p));
if (this.path === '') {
@@ -204,7 +203,7 @@ export class WriteEntry extends Minipass {
atime: this.portable ? undefined : this.header.atime,
ctime: this.portable ? undefined : this.header.ctime,
gid: this.portable ? undefined : this.header.gid,
mtime: this.noMtime ? undefined : (this.mtime || this.header.mtime),
mtime: this.noMtime ? undefined : this.mtime || this.header.mtime,
path: this[PREFIX](this.path),
linkpath: this.type === 'Link' && this.linkpath !== undefined ?
this[PREFIX](this.linkpath)
@@ -407,7 +406,7 @@ export class WriteEntry extends Minipass {
if (this.blockRemain) {
super.write(Buffer.alloc(this.blockRemain));
}
return this[CLOSE](er => er ? this.emit('error', er) : this.end());
return this[CLOSE](er => (er ? this.emit('error', er) : this.end()));
}
/* c8 ignore start */
if (!this.buf) {
@@ -455,7 +454,7 @@ export class WriteEntrySync extends WriteEntry {
try {
this[CLOSE](() => { });
}
catch (er) { }
catch { }
}
}
}
@@ -524,16 +523,13 @@ export class WriteEntryTar extends Minipass {
this.prefix = opt.prefix;
this.path = normalizeWindowsPath(readEntry.path);
this.mode =
readEntry.mode !== undefined ?
this[MODE](readEntry.mode)
: undefined;
readEntry.mode !== undefined ? this[MODE](readEntry.mode) : undefined;
this.uid = this.portable ? undefined : readEntry.uid;
this.gid = this.portable ? undefined : readEntry.gid;
this.uname = this.portable ? undefined : readEntry.uname;
this.gname = this.portable ? undefined : readEntry.gname;
this.size = readEntry.size;
this.mtime =
this.noMtime ? undefined : opt.mtime || readEntry.mtime;
this.mtime = this.noMtime ? undefined : opt.mtime || readEntry.mtime;
this.atime = this.portable ? undefined : readEntry.atime;
this.ctime = this.portable ? undefined : readEntry.ctime;
this.linkpath =
@@ -645,7 +641,10 @@ export class WriteEntryTar extends Minipass {
}
if (cb)
this.once('finish', cb);
chunk ? super.end(chunk, cb) : super.end(cb);
if (chunk)
super.end(chunk, cb);
else
super.end(cb);
/* c8 ignore stop */
return this;
}