-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dump files to the stdout if filename is specified. #562
base: main
Are you sure you want to change the base?
Conversation
let { dir } = cmd.args | ||
if (!link) throw ERR_INVALID_INPUT('<link> must be specified.') | ||
if (!dir) throw ERR_INVALID_INPUT('<dir> must be specified.') | ||
dir = dir === '-' ? '-' : (isAbsolute(dir) ? dir : resolve('.', dir)) | ||
if (dir === '-') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dir === '-' || getFileNameFromPearUrl
const pathParts = path.split('/') | ||
return pathParts[pathParts.length - 1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the return value is not used you could return a boolean instead
@@ -118,8 +118,8 @@ module.exports = async (ipc, argv = Bare.argv.slice(1)) => { | |||
const dump = command( | |||
'dump', | |||
summary('Synchronize files from key to dir'), | |||
arg('<link>', 'Pear link to dump from, supports pathname'), | |||
arg('<dir>', 'Directory path to dump to, may be - for stdout'), | |||
arg('<link>', 'Pear link to dump from, supports pathname. Pathname will always dump the the stdout'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicated "the" word
@@ -18,12 +18,36 @@ const output = outputter('stage', { | |||
} | |||
}) | |||
|
|||
function getFileNameFromPearUrl(url) { | |||
if (url.startsWith('pear://')) { | |||
const urlParts = url.slice(7).split('/') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use https://github.com/holepunchto/pear-link instead of manual parsing
please run npx standard --fix to reformat the code |
If file name is specified they will be dumped to the stdout, for example:
"pear:///path/to/file ." will dump to the stdout