@yarnpkg/fslib
Advanced tools
Comparing version 3.0.0-rc.48 to 3.0.0-rc.49
@@ -38,3 +38,2 @@ "use strict"; | ||
async function copyImpl(prelayout, postlayout, destinationFs, destination, sourceFs, source, opts) { | ||
var _a, _b, _c; | ||
const destinationStat = opts.didParentExist ? await maybeLStat(destinationFs, destination) : null; | ||
@@ -70,4 +69,4 @@ const sourceStat = await sourceFs.lstatPromise(source); | ||
// since otherwise we'd accidentally propagate the changes to all projects. | ||
if (((_a = opts.linkStrategy) === null || _a === void 0 ? void 0 : _a.type) !== `HardlinkFromIndex` || !sourceStat.isFile()) { | ||
if (updated || ((_b = destinationStat === null || destinationStat === void 0 ? void 0 : destinationStat.mtime) === null || _b === void 0 ? void 0 : _b.getTime()) !== mtime.getTime() || ((_c = destinationStat === null || destinationStat === void 0 ? void 0 : destinationStat.atime) === null || _c === void 0 ? void 0 : _c.getTime()) !== atime.getTime()) { | ||
if (opts.linkStrategy?.type !== `HardlinkFromIndex` || !sourceStat.isFile()) { | ||
if (updated || destinationStat?.mtime?.getTime() !== mtime.getTime() || destinationStat?.atime?.getTime() !== atime.getTime()) { | ||
postlayout.push(() => destinationFs.lutimesPromise(destination, atime, mtime)); | ||
@@ -146,3 +145,3 @@ updated = true; | ||
const isDestinationHardlinkedFromIndex = indexStat && destinationStat.dev === indexStat.dev && destinationStat.ino === indexStat.ino; | ||
const isIndexModified = (indexStat === null || indexStat === void 0 ? void 0 : indexStat.mtimeMs) !== defaultTimeMs; | ||
const isIndexModified = indexStat?.mtimeMs !== defaultTimeMs; | ||
if (isDestinationHardlinkedFromIndex) { | ||
@@ -249,4 +248,3 @@ // If the index is modified, we will want to repair it. However, the | ||
async function copyFile(prelayout, postlayout, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts) { | ||
var _a; | ||
if (((_a = opts.linkStrategy) === null || _a === void 0 ? void 0 : _a.type) === `HardlinkFromIndex`) { | ||
if (opts.linkStrategy?.type === `HardlinkFromIndex`) { | ||
return copyFileViaIndex(prelayout, postlayout, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts, opts.linkStrategy); | ||
@@ -253,0 +251,0 @@ } |
@@ -47,5 +47,4 @@ "use strict"; | ||
closeSync() { | ||
var _a, _b; | ||
this.throwIfClosed(); | ||
(_b = (_a = this.opts).onClose) === null || _b === void 0 ? void 0 : _b.call(_a); | ||
this.opts.onClose?.(); | ||
this.closed = true; | ||
@@ -52,0 +51,0 @@ } |
@@ -131,3 +131,3 @@ "use strict"; | ||
} | ||
createdDirectory !== null && createdDirectory !== void 0 ? createdDirectory : (createdDirectory = subPath); | ||
createdDirectory ??= subPath; | ||
if (chmod != null) | ||
@@ -166,3 +166,3 @@ await this.chmodPromise(subPath, chmod); | ||
} | ||
createdDirectory !== null && createdDirectory !== void 0 ? createdDirectory : (createdDirectory = subPath); | ||
createdDirectory ??= subPath; | ||
if (chmod != null) | ||
@@ -169,0 +169,0 @@ this.chmodSync(subPath, chmod); |
@@ -48,7 +48,6 @@ "use strict"; | ||
saveAndClose() { | ||
var _a; | ||
(0, watchFile_1.unwatchAllFiles)(this); | ||
if (this.mountInstances) { | ||
for (const [path, { childFs }] of this.mountInstances.entries()) { | ||
(_a = childFs.saveAndClose) === null || _a === void 0 ? void 0 : _a.call(childFs); | ||
childFs.saveAndClose?.(); | ||
this.mountInstances.delete(path); | ||
@@ -59,7 +58,6 @@ } | ||
discardAndClose() { | ||
var _a; | ||
(0, watchFile_1.unwatchAllFiles)(this); | ||
if (this.mountInstances) { | ||
for (const [path, { childFs }] of this.mountInstances.entries()) { | ||
(_a = childFs.discardAndClose) === null || _a === void 0 ? void 0 : _a.call(childFs); | ||
childFs.discardAndClose?.(); | ||
this.mountInstances.delete(path); | ||
@@ -764,3 +762,2 @@ } | ||
limitOpenFiles(max) { | ||
var _a, _b, _c; | ||
if (this.mountInstances === null) | ||
@@ -772,7 +769,7 @@ return; | ||
for (const [path, { childFs, expiresAt, refCount }] of this.mountInstances.entries()) { | ||
if (refCount !== 0 || ((_a = childFs.hasOpenFileHandles) === null || _a === void 0 ? void 0 : _a.call(childFs))) { | ||
if (refCount !== 0 || childFs.hasOpenFileHandles?.()) { | ||
continue; | ||
} | ||
else if (now >= expiresAt) { | ||
(_b = childFs.saveAndClose) === null || _b === void 0 ? void 0 : _b.call(childFs); | ||
childFs.saveAndClose?.(); | ||
this.mountInstances.delete(path); | ||
@@ -786,3 +783,3 @@ closeCount -= 1; | ||
} | ||
(_c = childFs.saveAndClose) === null || _c === void 0 ? void 0 : _c.call(childFs); | ||
childFs.saveAndClose?.(); | ||
this.mountInstances.delete(path); | ||
@@ -799,3 +796,2 @@ closeCount -= 1; | ||
async getMountPromise(p, accept) { | ||
var _a; | ||
if (this.mountInstances) { | ||
@@ -836,3 +832,3 @@ let cachedMountFs = this.mountInstances.get(p); | ||
finally { | ||
(_a = mountFs.saveAndClose) === null || _a === void 0 ? void 0 : _a.call(mountFs); | ||
mountFs.saveAndClose?.(); | ||
} | ||
@@ -842,3 +838,2 @@ } | ||
getMountSync(p, accept) { | ||
var _a; | ||
if (this.mountInstances) { | ||
@@ -867,3 +862,3 @@ let cachedMountFs = this.mountInstances.get(p); | ||
finally { | ||
(_a = childFs.saveAndClose) === null || _a === void 0 ? void 0 : _a.call(childFs); | ||
childFs.saveAndClose?.(); | ||
} | ||
@@ -870,0 +865,0 @@ } |
@@ -27,6 +27,5 @@ "use strict"; | ||
async appendFile(data, options) { | ||
var _e; | ||
try { | ||
this[kRef](this.appendFile); | ||
const encoding = (_e = (typeof options === `string` ? options : options === null || options === void 0 ? void 0 : options.encoding)) !== null && _e !== void 0 ? _e : undefined; | ||
const encoding = (typeof options === `string` ? options : options?.encoding) ?? undefined; | ||
return await this[kBaseFs].appendFilePromise(this.fd, data, encoding ? { encoding } : undefined); | ||
@@ -71,3 +70,2 @@ } | ||
async read(bufferOrOptions, offset, length, position) { | ||
var _e, _f, _g; | ||
try { | ||
@@ -77,7 +75,7 @@ this[kRef](this.read); | ||
if (!Buffer.isBuffer(bufferOrOptions)) { | ||
bufferOrOptions !== null && bufferOrOptions !== void 0 ? bufferOrOptions : (bufferOrOptions = {}); | ||
buffer = (_e = bufferOrOptions.buffer) !== null && _e !== void 0 ? _e : Buffer.alloc(16384); | ||
bufferOrOptions ??= {}; | ||
buffer = bufferOrOptions.buffer ?? Buffer.alloc(16384); | ||
offset = bufferOrOptions.offset || 0; | ||
length = (_f = bufferOrOptions.length) !== null && _f !== void 0 ? _f : buffer.byteLength; | ||
position = (_g = bufferOrOptions.position) !== null && _g !== void 0 ? _g : null; | ||
length = bufferOrOptions.length ?? buffer.byteLength; | ||
position = bufferOrOptions.position ?? null; | ||
} | ||
@@ -87,4 +85,4 @@ else { | ||
} | ||
offset !== null && offset !== void 0 ? offset : (offset = 0); | ||
length !== null && length !== void 0 ? length : (length = 0); | ||
offset ??= 0; | ||
length ??= 0; | ||
if (length === 0) { | ||
@@ -107,6 +105,5 @@ return { | ||
async readFile(options) { | ||
var _e; | ||
try { | ||
this[kRef](this.readFile); | ||
const encoding = (_e = (typeof options === `string` ? options : options === null || options === void 0 ? void 0 : options.encoding)) !== null && _e !== void 0 ? _e : undefined; | ||
const encoding = (typeof options === `string` ? options : options?.encoding) ?? undefined; | ||
return await this[kBaseFs].readFilePromise(this.fd, encoding); | ||
@@ -147,6 +144,5 @@ } | ||
async writeFile(data, options) { | ||
var _e; | ||
try { | ||
this[kRef](this.writeFile); | ||
const encoding = (_e = (typeof options === `string` ? options : options === null || options === void 0 ? void 0 : options.encoding)) !== null && _e !== void 0 ? _e : undefined; | ||
const encoding = (typeof options === `string` ? options : options?.encoding) ?? undefined; | ||
await this[kBaseFs].writeFilePromise(this.fd, data, encoding); | ||
@@ -163,3 +159,3 @@ } | ||
const [buffer, offset, length, position] = args; | ||
const bytesWritten = await this[kBaseFs].writePromise(this.fd, buffer, offset !== null && offset !== void 0 ? offset : undefined, length !== null && length !== void 0 ? length : undefined, position !== null && position !== void 0 ? position : undefined); | ||
const bytesWritten = await this[kBaseFs].writePromise(this.fd, buffer, offset ?? undefined, length ?? undefined, position ?? undefined); | ||
return { bytesWritten, buffer }; | ||
@@ -166,0 +162,0 @@ } |
@@ -84,3 +84,3 @@ "use strict"; | ||
// Preserve any util.promisify implementations | ||
if (typeof (orig === null || orig === void 0 ? void 0 : orig[util_1.promisify.custom]) !== `undefined`) { | ||
if (typeof orig?.[util_1.promisify.custom] !== `undefined`) { | ||
replacement[util_1.promisify.custom] = orig[util_1.promisify.custom]; | ||
@@ -87,0 +87,0 @@ } |
@@ -142,3 +142,3 @@ "use strict"; | ||
for (const key in stats) { | ||
if (Object.prototype.hasOwnProperty.call(stats, key)) { | ||
if (Object.hasOwn(stats, key)) { | ||
const element = stats[key]; | ||
@@ -165,3 +165,3 @@ if (typeof element === `number`) { | ||
for (const key in stats) { | ||
if (Object.prototype.hasOwnProperty.call(stats, key)) { | ||
if (Object.hasOwn(stats, key)) { | ||
const element = stats[key]; | ||
@@ -168,0 +168,0 @@ if (typeof element === `number`) { |
{ | ||
"name": "@yarnpkg/fslib", | ||
"version": "3.0.0-rc.48", | ||
"version": "3.0.0-rc.49", | ||
"stableVersion": "2.10.3", | ||
@@ -16,3 +16,3 @@ "license": "BSD-2-Clause", | ||
"devDependencies": { | ||
"@yarnpkg/libzip": "^3.0.0-rc.48" | ||
"@yarnpkg/libzip": "^3.0.0-rc.49" | ||
}, | ||
@@ -19,0 +19,0 @@ "scripts": { |
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
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
228233
5913