tar
Version:
tar for JavaScript
79 lines • 2.8 kB
TypeScript
/**
* The option aliases of the commands: the short names of the tar
* program, and the long names of version 7. Each alias has the name
* of its option.
*/
export declare const aliases: {
readonly C: "cwd";
readonly f: "file";
readonly z: "gzip";
readonly P: "preservePaths";
readonly U: "unlink";
readonly 'strip-components': "strip";
readonly stripComponents: "strip";
readonly 'keep-newer': "newer";
readonly keepNewer: "newer";
readonly 'keep-newer-files': "newer";
readonly keepNewerFiles: "newer";
readonly k: "keep";
readonly 'keep-existing': "keep";
readonly keepExisting: "keep";
readonly m: "noMtime";
readonly 'no-mtime': "noMtime";
readonly p: "preserveOwner";
readonly L: "follow";
readonly h: "follow";
readonly onentry: "onEntry";
readonly onReadEntry: "onEntry";
};
/** The alias names, and the name of the option of each one. */
export type Aliases = typeof aliases;
/** The names of the options that have an alias. */
export type Aliased = Aliases[keyof Aliases];
/** The alias names of the option `K`. */
export type AliasOf<K> = {
[A in keyof Aliases]: Aliases[A] extends K ? A : never;
}[keyof Aliases];
/**
* For each option `K` of `T`, an object type that requires the option
* or one of its aliases.
*/
export type RequiredOption<T, K extends keyof T> = [
K
] extends [never] ? unknown : (K extends unknown ? (x: {
v: {
[N in K | AliasOf<K>]: {
[P in N]: T[K];
};
}[K | AliasOf<K>];
}) => void : never) extends (x: infer I extends {
v: unknown;
}) => void ? I['v'] : never;
/**
* The option type `T` of a command, and the aliases of its options.
* An alias has the type of its option. An option that `T` requires
* can be given with its name or with an alias.
*/
export type WithAliases<T> = T extends unknown ? Omit<T, Aliased> & Partial<Pick<T, keyof T & Aliased>> & {
[A in keyof Aliases as Aliases[A] extends keyof T ? A : never]?: T[Aliases[A] & keyof T];
} & ('chmod' extends keyof T ? {
/** `noChmod: false` is `chmod: true`, if `chmod` is not set. */
noChmod?: boolean;
} : unknown) & RequiredOption<T, {
[K in keyof T]-?: object extends Pick<T, K> ? never : K;
}[keyof T] & Aliased> : never;
/** The `file` option, with its name or with its alias. */
export type FileOption = RequiredOption<{
file: string;
}, 'file'>;
/** No `file` option. */
export type NoFileOption = {
[N in 'file' | AliasOf<'file'>]?: undefined;
};
/**
* A copy of the options, with no prototype, that has the name of the
* option in place of each alias. An option that is set wins over its
* aliases.
*/
export declare const dealias: <T extends object>(options: WithAliases<T>) => T;
//# sourceMappingURL=dealias.d.ts.map