Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
options.js54 linesDownload Raw Back to esm
1// turn tar(1) style args like `C` into the more verbose things like `cwd`
2const argmap = new Map([
3    ['C', 'cwd'],
4    ['f', 'file'],
5    ['z', 'gzip'],
6    ['P', 'preservePaths'],
7    ['U', 'unlink'],
8    ['strip-components', 'strip'],
9    ['stripComponents', 'strip'],
10    ['keep-newer', 'newer'],
11    ['keepNewer', 'newer'],
12    ['keep-newer-files', 'newer'],
13    ['keepNewerFiles', 'newer'],
14    ['k', 'keep'],
15    ['keep-existing', 'keep'],
16    ['keepExisting', 'keep'],
17    ['m', 'noMtime'],
18    ['no-mtime', 'noMtime'],
19    ['p', 'preserveOwner'],
20    ['L', 'follow'],
21    ['h', 'follow'],
22    ['onentry', 'onReadEntry'],
23]);
24export const isSyncFile = (o) => !!o.sync && !!o.file;
25export const isAsyncFile = (o) => !o.sync && !!o.file;
26export const isSyncNoFile = (o) => !!o.sync && !o.file;
27export const isAsyncNoFile = (o) => !o.sync && !o.file;
28export const isSync = (o) => !!o.sync;
29export const isAsync = (o) => !o.sync;
30export const isFile = (o) => !!o.file;
31export const isNoFile = (o) => !o.file;
32const dealiasKey = (k) => {
33    const d = argmap.get(k);
34    if (d)
35        return d;
36    return k;
37};
38export const dealias = (opt = {}) => {
39    if (!opt)
40        return {};
41    const result = {};
42    for (const [key, v] of Object.entries(opt)) {
43        // TS doesn't know that aliases are going to always be the same type
44        const k = dealiasKey(key);
45        result[k] = v;
46    }
47    // affordance for deprecated noChmod -> chmod
48    if (result.chmod === undefined && result.noChmod === false) {
49        result.chmod = true;
50    }
51    delete result.noChmod;
52    return result;
53};
54//# sourceMappingURL=options.js.map
codekingpro/portable-devtools · Team Ai