Add support for user-specifiable name for cache directory#5
Add support for user-specifiable name for cache directory#5herber wants to merge 5 commits intolukeed:masterfrom
Conversation
lukeed
left a comment
There was a problem hiding this comment.
Hey, thanks~!!
Left some comments for you.
Do you mind sharing your use case for this? IMO, it'd be better to have everything shared from .gittar explicitly so that users don't end up with copies of the same tarball in different root locations.
Of course, this pkg isn't that popular to really make that a concern, but if that ever were the case, I'd be afraid of having something existing in multiple locations, when the underlying gittar can know for certain if it has it. Also, current approach allows for easy cleanup -- single directory to remove.
lib/index.js
Outdated
| function getTarFile(obj) { | ||
| return path.join(DIR, obj.site, obj.repo, `${obj.type}.tar.gz`); | ||
| function getTarFile(obj, name) { | ||
| return path.join(name !== undefined ? path.join(HOME, '.' + name) : DIR, obj.site, obj.repo, `${obj.type}.tar.gz`); |
There was a problem hiding this comment.
This could be:
function getTarFile(obj, name) {
let dir = name ? path.join(HOME, `.${name}`) : DIR;
return path.join(dir, obj.site, obj.repo, `${obj.type}.tar.gz`);
}
lib/index.js
Outdated
| return new Promise((res, rej) => { | ||
| const ok = _ => res(dest); | ||
| opts = Object.assign({ strip:1 }, opts, { file, cwd:dest }); | ||
| opts = Object.assign({ strip:1 }, opts, { file, cwd:dest, name: undefined }); |
There was a problem hiding this comment.
This would have to be
opts = Object.assign({ strip:1, name:null }, opts, { file, cwd:dest });Otherwise you're always overwriting a user-specified opts.name with name:undefined.
Used
nullhere just for shorthand; that's not the problem in this case. :D
|
Thanks for the suggestions! I added this feature, because some users might worry about the |
Users should be able to choose the name of gittar's directory in
~/.Instead of
.gittarusers can choose any name.Example
gittar.fetch
gittar.extract