Server IP : 85.214.239.14 / Your IP : 3.137.210.133 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/3/cwd/usr/lib/node_modules/npm/node_modules/cacache/node_modules/tar/dist/esm/ |
Upload File : |
import { WriteStream, WriteStreamSync } from '@isaacs/fs-minipass'; import path from 'node:path'; import { list } from './list.js'; import { makeCommand } from './make-command.js'; import { Pack, PackSync } from './pack.js'; const createFileSync = (opt, files) => { const p = new PackSync(opt); const stream = new WriteStreamSync(opt.file, { mode: opt.mode || 0o666, }); p.pipe(stream); addFilesSync(p, files); }; const createFile = (opt, files) => { const p = new Pack(opt); const stream = new WriteStream(opt.file, { mode: opt.mode || 0o666, }); p.pipe(stream); const promise = new Promise((res, rej) => { stream.on('error', rej); stream.on('close', res); p.on('error', rej); }); addFilesAsync(p, files); return promise; }; const addFilesSync = (p, files) => { files.forEach(file => { if (file.charAt(0) === '@') { list({ file: path.resolve(p.cwd, file.slice(1)), sync: true, noResume: true, onReadEntry: entry => p.add(entry), }); } else { p.add(file); } }); p.end(); }; const addFilesAsync = async (p, files) => { for (let i = 0; i < files.length; i++) { const file = String(files[i]); if (file.charAt(0) === '@') { await list({ file: path.resolve(String(p.cwd), file.slice(1)), noResume: true, onReadEntry: entry => { p.add(entry); }, }); } else { p.add(file); } } p.end(); }; const createSync = (opt, files) => { const p = new PackSync(opt); addFilesSync(p, files); return p; }; const createAsync = (opt, files) => { const p = new Pack(opt); addFilesAsync(p, files); return p; }; export const create = makeCommand(createFileSync, createFile, createSync, createAsync, (_opt, files) => { if (!files?.length) { throw new TypeError('no paths specified to add to archive'); } }); //# sourceMappingURL=create.js.map