-
Notifications
You must be signed in to change notification settings - Fork 15
Dump files to the stdout if filename is specified. #562
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,12 +18,36 @@ const output = outputter('stage', { | |
} | ||
}) | ||
|
||
function getFileNameFromPearUrl(url) { | ||
if (url.startsWith('pear://')) { | ||
const urlParts = url.slice(7).split('/') | ||
const path = urlParts.slice(1).join('/') | ||
if (path) { | ||
const pathParts = path.split('/') | ||
return pathParts[pathParts.length - 1] | ||
Comment on lines
+26
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
} else { | ||
return null; | ||
} | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
module.exports = (ipc) => async function dump (cmd) { | ||
const { dryRun, checkout, json, ask, force } = cmd.flags | ||
const { link } = cmd.args | ||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. dir === '-' || getFileNameFromPearUrl |
||
dir = '-' | ||
} else if (getFileNameFromPearUrl(link)) { | ||
dir = '-' | ||
} | ||
else { | ||
dir = isAbsolute(dir) ? dir : resolve('.', dir); | ||
} | ||
|
||
await output(json, ipc.dump({ id: Bare.pid, link, dir, dryRun, checkout, force }), { ask }, ipc) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. duplicated "the" word |
||
arg('<dir>', 'Directory path to dump to, may be - for stdout.'), | ||
flag('--dry-run|-d', 'Execute a dump without writing'), | ||
flag('--checkout <n>', 'Dump from specified checkout, n is version length'), | ||
flag('--json', 'Newline delimited JSON output'), | ||
|
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