UNPKG

extract-base-iterator

Version:

Base iterator for extract iterators like tar-iterator and zip-iterator

18 lines (17 loc) 835 B
// lutimes - set times on symlinks without following them // fs.lutimes was added in Node.js 14.5.0 // For older versions, we skip setting times on symlinks (no good alternative) import fs from 'fs'; // biome-ignore lint/suspicious/noExplicitAny: fs.lutimes not in older @types/node const HAS_LUTIMES = typeof fs.lutimes === 'function'; export default function lutimes(fullPath, entry, options, callback) { if (HAS_LUTIMES) { const now = options.now || new Date(); // biome-ignore lint/suspicious/noExplicitAny: fs.lutimes not in older @types/node fs.lutimes(fullPath, now, new Date(entry.mtime), callback); } else { // On older Node versions, skip setting times on symlinks // fs.utimes follows symlinks and will fail with ENOENT if target doesn't exist callback(null); } }