feat(xo-cli): support @=- to output to stdout
This commit is contained in:
@@ -27,6 +27,7 @@ const prettyMs = require('pretty-ms')
|
||||
const progressStream = require('progress-stream')
|
||||
const pw = require('pw')
|
||||
const Xo = require('xo-lib').default
|
||||
const { PassThrough } = require('stream')
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
@@ -50,6 +51,17 @@ async function connect() {
|
||||
return xo
|
||||
}
|
||||
|
||||
function createOutputStream(path) {
|
||||
if (path !== undefined && path !== '-') {
|
||||
return createWriteStream(path)
|
||||
}
|
||||
|
||||
// introduce a through stream because stdout is not a normal stream!
|
||||
const stream = new PassThrough()
|
||||
stream.pipe(process.stdout)
|
||||
return stream
|
||||
}
|
||||
|
||||
const FLAG_RE = /^--([^=]+)(?:=([^]*))?$/
|
||||
function extractFlags(args) {
|
||||
const flags = {}
|
||||
@@ -375,7 +387,7 @@ async function call(args) {
|
||||
if (key === '$getFrom') {
|
||||
ensurePathParam(method, file)
|
||||
url = resolveUrl(baseUrl, result[key])
|
||||
const output = createWriteStream(file)
|
||||
const output = createOutputStream(file)
|
||||
const response = await hrp(url)
|
||||
|
||||
const progress = progressStream(
|
||||
|
||||
Reference in New Issue
Block a user