-
-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1289 from okonet/updates-2023-04-20
Drop Node.js v14, run tests for 20, update dependencies
- Loading branch information
Showing
43 changed files
with
2,783 additions
and
2,137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"printWidth": 100, | ||
"singleQuote": true, | ||
"semi": false | ||
"semi": false, | ||
"trailingComma": "es5" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,64 @@ | ||
const getMainRendererOptions = ({ debug, quiet }, env) => { | ||
if (quiet) return { renderer: 'silent' } | ||
import { EOL } from 'node:os' | ||
import { Writable } from 'node:stream' | ||
|
||
import { ListrLogger, ProcessOutput } from 'listr2' | ||
|
||
const EOLRegex = new RegExp(EOL + '$') | ||
|
||
const bindLogger = (consoleLogMethod) => | ||
new Writable({ | ||
write: function (chunk, encoding, next) { | ||
consoleLogMethod(chunk.toString().replace(EOLRegex, '')) | ||
next() | ||
}, | ||
}) | ||
|
||
const getMainRendererOptions = ({ debug, quiet }, logger, env) => { | ||
if (quiet) { | ||
return { | ||
renderer: 'silent', | ||
} | ||
} | ||
|
||
if (env.NODE_ENV === 'test') { | ||
return { | ||
renderer: 'test', | ||
rendererOptions: { | ||
logger: new ListrLogger({ | ||
processOutput: new ProcessOutput(bindLogger(logger.log), bindLogger(logger.error)), | ||
}), | ||
}, | ||
} | ||
} | ||
|
||
// Better support for dumb terminals: https://en.wikipedia.org/wiki/Computer_terminal#Dumb_terminals | ||
const isDumbTerminal = env.TERM === 'dumb' | ||
if (debug || isDumbTerminal || env.NODE_ENV === 'test') return { renderer: 'verbose' } | ||
return { renderer: 'update', rendererOptions: { dateFormat: false } } | ||
} | ||
if (debug || env.TERM === 'dumb') { | ||
return { | ||
renderer: 'verbose', | ||
} | ||
} | ||
|
||
const getFallbackRenderer = ({ renderer }, { FORCE_COLOR }) => { | ||
if (renderer === 'silent') { | ||
return 'silent' | ||
return { | ||
renderer: 'update', | ||
rendererOptions: { | ||
formatOutput: 'truncate', | ||
}, | ||
} | ||
} | ||
|
||
// If colors are being forced, then also force non-fallback rendering | ||
if (Number(FORCE_COLOR) > 0) { | ||
const getFallbackRenderer = ({ renderer }, { FORCE_COLOR }) => { | ||
if (renderer === 'silent' || renderer === 'test' || Number(FORCE_COLOR) > 0) { | ||
return renderer | ||
} | ||
|
||
return 'verbose' | ||
} | ||
|
||
export const getRenderer = (options, env = process.env) => { | ||
const mainRendererOptions = getMainRendererOptions(options, env) | ||
export const getRenderer = (options, logger, env = process.env) => { | ||
const mainRendererOptions = getMainRendererOptions(options, logger, env) | ||
|
||
return { | ||
...mainRendererOptions, | ||
nonTTYRenderer: getFallbackRenderer(mainRendererOptions, env), | ||
fallbackRenderer: getFallbackRenderer(mainRendererOptions, env), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.