Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
make-command.js61 linesDownload Raw Back to commonjs
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        if (!entries) {
16            entries = [];
17        }
18        else {
19            entries = Array.from(entries);
20        }
21        const opt = (0, options_js_1.dealias)(opt_);
22        validate?.(opt, entries);
23        if ((0, options_js_1.isSyncFile)(opt)) {
24            if (typeof cb === 'function') {
25                throw new TypeError('callback not supported for sync tar functions');
26            }
27            return syncFile(opt, entries);
28        }
29        else if ((0, options_js_1.isAsyncFile)(opt)) {
30            const p = asyncFile(opt, entries);
31            // weirdness to make TS happy
32            const c = cb ? cb : undefined;
33            return c ? p.then(() => c(), c) : p;
34        }
35        else if ((0, options_js_1.isSyncNoFile)(opt)) {
36            if (typeof cb === 'function') {
37                throw new TypeError('callback not supported for sync tar functions');
38            }
39            return syncNoFile(opt, entries);
40        }
41        else if ((0, options_js_1.isAsyncNoFile)(opt)) {
42            if (typeof cb === 'function') {
43                throw new TypeError('callback only supported with file option');
44            }
45            return asyncNoFile(opt, entries);
46            /* c8 ignore start */
47        }
48        else {
49            throw new Error('impossible options??');
50        }
51        /* c8 ignore stop */
52    }, {
53        syncFile,
54        asyncFile,
55        syncNoFile,
56        asyncNoFile,
57        validate,
58    });
59};
60exports.makeCommand = makeCommand;
61//# sourceMappingURL=make-command.js.map
codekingpro/portable-devtools · Team Ai