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
fix: colored output #1944
fix: colored output #1944
Changes from 1 commit
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
stats: { | ||
colors: false, | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
stats: { | ||
colors: true, | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
'use strict'; | ||
const { run } = require('../utils/test-utils'); | ||
const { resolve } = require('path'); | ||
const { options: coloretteOptions } = require('colorette'); | ||
|
||
describe('colorts', () => { | ||
it('should output by default', () => { | ||
const { stderr, stdout, exitCode } = run(__dirname); | ||
|
||
expect(stderr).toBeFalsy(); | ||
expect(stdout).toContain(coloretteOptions.enabled ? '\u001b[1m\u001b[32msuccessfully\u001b[39m\u001b[22m' : 'successfully'); | ||
expect(exitCode).toBe(0); | ||
}); | ||
|
||
it('should work with the "stats" option from flags', () => { | ||
const { stderr, stdout, exitCode } = run(__dirname, ['--stats=verbose']); | ||
|
||
expect(stderr).toBeFalsy(); | ||
expect(stdout).toContain(coloretteOptions.enabled ? '\u001b[1m\u001b[32msuccessfully\u001b[39m\u001b[22m' : 'successfully'); | ||
expect(exitCode).toBe(0); | ||
}); | ||
|
||
it('should work with the "stats" option from the configuration', () => { | ||
const { stderr, stdout, exitCode } = run(__dirname, [`--config=${resolve(__dirname, './stats-string.webpack.config.js')}`]); | ||
|
||
expect(stderr).toBeFalsy(); | ||
expect(stdout).toContain(coloretteOptions.enabled ? '\u001b[1m\u001b[32msuccessfully\u001b[39m\u001b[22m' : 'successfully'); | ||
expect(exitCode).toBe(0); | ||
}); | ||
|
||
it('should work with the "stats" option from the configuration #1', () => { | ||
const { stderr, stdout, exitCode } = run(__dirname, [`--config=${resolve(__dirname, './stats-boolean.webpack.config.js')}`]); | ||
|
||
expect(stderr).toBeFalsy(); | ||
expect(stdout).toContain(coloretteOptions.enabled ? '\u001b[1m\u001b[32msuccessfully\u001b[39m\u001b[22m' : 'successfully'); | ||
expect(exitCode).toBe(0); | ||
}); | ||
|
||
it('should work with the "stats" option from the configuration #2', () => { | ||
const { stderr, stdout, exitCode } = run(__dirname, [`--config=${resolve(__dirname, './no-stats.webpack.config.js')}`]); | ||
|
||
expect(stderr).toBeFalsy(); | ||
expect(stdout).toContain(coloretteOptions.enabled ? '\u001b[1m\u001b[32msuccessfully\u001b[39m\u001b[22m' : 'successfully'); | ||
expect(exitCode).toBe(0); | ||
}); | ||
|
||
it('should work with the "stats" option from the configuration #3', () => { | ||
const { stderr, stdout, exitCode } = run(__dirname, [`--config=${resolve(__dirname, './colors-true.webpack.config.js')}`]); | ||
|
||
expect(stderr).toBeFalsy(); | ||
expect(stdout).toContain(coloretteOptions.enabled ? '\u001b[1m\u001b[32msuccessfully\u001b[39m\u001b[22m' : 'successfully'); | ||
expect(exitCode).toBe(0); | ||
}); | ||
|
||
it('should work with the "stats" option from the configuration #4', () => { | ||
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. Can we also add tests with both config and flags? 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. Feel free to do it after this will be merged, I really don't have time to solve all problems from previously webpack-cli contrbutors, I'm very disappointed, I want to fix basic regressions and rewrite most of code, because here bug on almost every line of code |
||
const { stderr, stdout, exitCode } = run(__dirname, [`--config=${resolve(__dirname, './colors-false.webpack.config.js')}`]); | ||
|
||
expect(stderr).toBeFalsy(); | ||
expect(stdout).not.toContain('\u001b[1m\u001b[32msuccessfully\u001b[39m\u001b[22m'); | ||
expect(stdout).toContain('successfully'); | ||
expect(exitCode).toBe(0); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
name: 'test', | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const foo = 'bar'; | ||
|
||
export default foo |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
stats: true, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
stats: 'verbose', | ||
}; |
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.
can give relative path,
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.
No need to use aliases in tests, except tests on aliases, we can rename them (this can happen more often than renaming basic options)