codekingpro/portable-devtools
115k
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.makeCommand = void 0;
4const options_js_1 = require("./options.js");
5const makeCommand = (syncFile, asyncFile, syncNoFile, asyncNoFile, validate) => {
6 return Object.assign((opt_ = [], entries, cb) => {
7 if (Array.isArray(opt_)) {
8 entries = opt_;
9 opt_ = {};
10 }
11 if (typeof entries === 'function') {
12 cb = entries;
13 entries = undefined;
14 }
15 entries = !entries ? [] : Array.from(entries);
16 const opt = (0, options_js_1.dealias)(opt_);
17 validate?.(opt, entries);
18 if ((0, options_js_1.isSyncFile)(opt)) {
19 if (typeof cb === 'function') {
20 throw new TypeError('callback not supported for sync tar functions');
21 }
22 return syncFile(opt, entries);
23 }
24 else if ((0, options_js_1.isAsyncFile)(opt)) {
25 const p = asyncFile(opt, entries);
26 return cb ? p.then(() => cb(), cb) : p;
27 }
28 else if ((0, options_js_1.isSyncNoFile)(opt)) {
29 if (typeof cb === 'function') {
30 throw new TypeError('callback not supported for sync tar functions');
31 }
32 return syncNoFile(opt, entries);
33 }
34 else if ((0, options_js_1.isAsyncNoFile)(opt)) {
35 if (typeof cb === 'function') {
36 throw new TypeError('callback only supported with file option');
37 }
38 return asyncNoFile(opt, entries);
39 /* c8 ignore start */
40 }
41 throw new Error('impossible options??');
42 /* c8 ignore stop */
43 }, {
44 syncFile,
45 asyncFile,
46 syncNoFile,
47 asyncNoFile,
48 validate,
49 });
50};
51exports.makeCommand = makeCommand;
52//# sourceMappingURL=make-command.js.map