UNPKG

tar

Version:
166 lines • 8.03 kB
"use strict"; // The entry point for Node.js, and for each runtime that has the // `node:` modules. It has all that the core entry point has. Each // command gets defaults for the options that the core cannot know: // the file system, the working directory, the platform, the user of // the process, and the codecs of `node:zlib`. It adds the sync // commands. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); var __exportStar = (this && this.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.u = exports.r = exports.t = exports.x = exports.delete = exports.deleteSync = exports.updateSync = exports.update = exports.replaceSync = exports.replace = exports.extractSync = exports.extract = exports.listSync = exports.list = exports.entriesSync = exports.entries = exports.codecStream = exports.zlibCodecs = exports.UnpackSync = exports.ReadEntrySync = exports.PackSync = exports.TarReaderSync = void 0; exports.create = create; exports.c = create; exports.createSync = createSync; exports.create = create; exports.c = create; const nodeFs = __importStar(require("node:fs")); const nodeFsPromises = __importStar(require("node:fs/promises")); const node_path_1 = require("node:path"); const core = __importStar(require("../index.js")); const create_js_1 = require("../create.js"); const delete_js_1 = require("../delete.js"); const dealias_js_1 = require("../dealias.js"); const entries_js_1 = require("../entries.js"); const extract_js_1 = require("../extract.js"); const list_js_1 = require("../list.js"); const replace_js_1 = require("../replace.js"); const update_js_1 = require("../update.js"); const codecs_js_1 = require("./codecs.js"); __exportStar(require("../index.js"), exports); var entries_js_2 = require("../entries.js"); Object.defineProperty(exports, "TarReaderSync", { enumerable: true, get: function () { return entries_js_2.TarReaderSync; } }); var pack_js_1 = require("../pack.js"); Object.defineProperty(exports, "PackSync", { enumerable: true, get: function () { return pack_js_1.PackSync; } }); var read_entry_js_1 = require("../read-entry.js"); Object.defineProperty(exports, "ReadEntrySync", { enumerable: true, get: function () { return read_entry_js_1.ReadEntrySync; } }); var unpack_js_1 = require("../unpack.js"); Object.defineProperty(exports, "UnpackSync", { enumerable: true, get: function () { return unpack_js_1.UnpackSync; } }); var codecs_js_2 = require("./codecs.js"); Object.defineProperty(exports, "zlibCodecs", { enumerable: true, get: function () { return codecs_js_2.zlibCodecs; } }); Object.defineProperty(exports, "codecStream", { enumerable: true, get: function () { return codecs_js_2.codecStream; } }); const fs = nodeFsPromises; const fsSync = nodeFs; const platform = process.platform === 'win32' ? 'win32' : 'posix'; const codecs = (0, codecs_js_1.zlibCodecs)(); // A copy of the options, with the name of the option in place of // each alias, and a default for each option that is not set. `T` is // the option type of the core command. const fill = (options, fs, paths) => { const opt = (0, dealias_js_1.dealias)(options); opt.fs ??= fs; opt.platform ??= platform; opt.codecs = [...(opt.codecs ?? []), ...codecs]; // A command that reads an archive, and writes no file, does not // need the working directory or the user. if (paths) { // `resolve` adds `process.cwd()` to a relative path. opt.cwd = (0, node_path_1.resolve)(opt.cwd ?? ''); opt.processUid ??= process.getuid?.(); opt.processGid ??= process.getgid?.(); opt.processUname ??= process.env.USER; if (opt.chmod) opt.processUmask ??= process.umask(); } return opt; }; /** * Read the entries of an archive. Gzip, brotli, and zstd input is * decompressed, if the runtime has the format. */ const entries = (input, opt = {}) => core.entries(input, fill(opt, fs, false)); exports.entries = entries; /** The sync form of `entries`. */ const entriesSync = (input, opt = {}) => (0, entries_js_1.entriesSync)(input, fill(opt, fsSync, false)); exports.entriesSync = entriesSync; /** * Call `opt.onEntry` with each entry of an archive. If `files` is * set, only with the entries that it lists, and the entries in the * directories that it lists. */ const list = (opt, files) => core.list(fill(opt, fs, false), files); exports.list = list; exports.t = exports.list; /** The sync form of `list`. */ const listSync = (opt, files) => (0, list_js_1.listSync)(fill(opt, fsSync, false), files); exports.listSync = listSync; /** * Extract the entries of an archive into the directory `opt.cwd`. * If `files` is set, only the entries that it lists, and the entries * in the directories that it lists. */ const extract = (opt, files) => core.extract(fill(opt, fs, true), files); exports.extract = extract; exports.x = exports.extract; /** The sync form of `extract`. */ const extractSync = (opt, files) => (0, extract_js_1.extractSync)(fill(opt, fsSync, true), files); exports.extractSync = extractSync; function create(opt, files) { return core.create(fill(opt, fs, true), files); } function createSync(opt, files) { return (0, create_js_1.createSync)(fill(opt, fsSync, true), files); } /** Add the files to the end of an archive file that is not compressed. */ const replace = (opt, files) => core.replace(fill(opt, fs, true), files); exports.replace = replace; exports.r = exports.replace; /** The sync form of `replace`. */ const replaceSync = (opt, files) => (0, replace_js_1.replaceSync)(fill(opt, fsSync, true), files); exports.replaceSync = replaceSync; /** * The same as `replace`, but a file is added only if it is newer than * the last entry of the archive that has its path. A directory is * always added, and each path in it is checked. */ const update = (opt, files) => core.update(fill(opt, fs, true), files); exports.update = update; exports.u = exports.update; /** The sync form of `update`. */ const updateSync = (opt, files) => (0, update_js_1.updateSync)(fill(opt, fsSync, true), files); exports.updateSync = updateSync; /** * Remove entries from an archive file: each entry that `files` lists, * and each entry in a directory that it lists. With `opt.filter`, * only if the filter also returns true. */ const del = (opt, files) => core.delete(fill(opt, fs, false), files); exports.delete = del; /** The sync form of `delete`. */ const deleteSync = (opt, files) => (0, delete_js_1.deleteSync)(fill(opt, fsSync, false), files); exports.deleteSync = deleteSync; //# sourceMappingURL=index.js.map