tar
Version:
tar for JavaScript
46 lines • 1.24 kB
JavaScript
/**
* 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 const aliases = {
C: 'cwd',
f: 'file',
z: 'gzip',
P: 'preservePaths',
U: 'unlink',
'strip-components': 'strip',
stripComponents: 'strip',
'keep-newer': 'newer',
keepNewer: 'newer',
'keep-newer-files': 'newer',
keepNewerFiles: 'newer',
k: 'keep',
'keep-existing': 'keep',
keepExisting: 'keep',
m: 'noMtime',
'no-mtime': 'noMtime',
p: 'preserveOwner',
L: 'follow',
h: 'follow',
onentry: 'onEntry',
onReadEntry: 'onEntry',
};
/**
* 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 const dealias = (options) => {
const opt = Object.assign(Object.create(null), options);
for (const [alias, name] of Object.entries(aliases)) {
if (opt[alias] !== undefined)
opt[name] ??= opt[alias];
delete opt[alias];
}
if (opt.noChmod === false)
opt.chmod ??= true;
delete opt.noChmod;
return opt;
};
//# sourceMappingURL=dealias.js.map