Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
295 additions
and
305 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
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,25 +1,11 @@ | ||
const util = require('util'); | ||
const { red, cyan, yellow, green } = require('colorette'); | ||
|
||
const write = (prefix = '[webpack-cli] ', color = (val) => val) => { | ||
return (...args) => { | ||
const str = prefix + color(util.format(...args)); | ||
process.stderr.write(str + '\n'); | ||
}; | ||
}; | ||
|
||
module.exports = { | ||
error: write(undefined, red), | ||
warn: write(undefined, yellow), | ||
info: write(undefined, cyan), | ||
log: write(), | ||
|
||
/** | ||
* @deprecated use info | ||
*/ | ||
success: write(undefined, green), | ||
/** | ||
* @deprecated use info | ||
*/ | ||
raw: write(''), | ||
error: (val) => console.error(`[webpack-cli] ${red(util.format(val))}`), | ||
warn: (val) => console.warn(`[webpack-cli] ${yellow(val)}`), | ||
info: (val) => console.info(`[webpack-cli] ${cyan(val)}`), | ||
success: (val) => console.log(`[webpack-cli] ${green(val)}`), | ||
log: (val) => console.log(`[webpack-cli] ${val}`), | ||
raw: (val) => console.log(val), | ||
}; |
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,80 +1,81 @@ | ||
'use strict'; | ||
const { run, isWebpack5 } = require('../utils/test-utils'); | ||
const { run } = require('../utils/test-utils'); | ||
const { resolve } = require('path'); | ||
const { options: coloretteOptions } = require('colorette'); | ||
const { options: coloretteOptions, green } = require('colorette'); | ||
|
||
describe.skip('colorts', () => { | ||
it('should output by default', () => { | ||
const { stderr, exitCode } = run(__dirname); | ||
it.only('should output by default', () => { | ||
const { stdout, exitCode } = run(__dirname, ['--color']); | ||
|
||
const output = isWebpack5 ? '<i> [webpack-cli] output:' : 'main.js'; | ||
expect(stderr).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); | ||
// const output = 'main.js'; | ||
console.log(coloretteOptions.enabled, [stdout], green('main.js')); | ||
expect(stdout).toContain(green('main.js')); | ||
expect(exitCode).toBe(0); | ||
}); | ||
|
||
it('should work with the "stats" option from flags', () => { | ||
const { stderr, exitCode } = run(__dirname, ['--stats=verbose']); | ||
const { stdout, exitCode } = run(__dirname, ['--stats=verbose']); | ||
|
||
const output = isWebpack5 ? '<i> [webpack-cli] output:' : 'main.js'; | ||
expect(stderr).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); | ||
const output = 'main.js'; | ||
expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); | ||
expect(exitCode).toBe(0); | ||
}); | ||
|
||
it('should work with the "stats" option from flags and from configuration', () => { | ||
const { stderr, exitCode } = run(__dirname, ['--stats=verbose', `--config=${resolve(__dirname, './no-stats.webpack.config.js')}`]); | ||
const { stdout, exitCode } = run(__dirname, ['--stats=verbose', `--config=${resolve(__dirname, './no-stats.webpack.config.js')}`]); | ||
|
||
const output = isWebpack5 ? '<i> [webpack-cli] output:' : 'main.js'; | ||
expect(stderr).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); | ||
const output = 'main.js'; | ||
expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); | ||
expect(exitCode).toBe(0); | ||
}); | ||
|
||
it('should work with the "stats" option from flags and from configuration #2', () => { | ||
const { stderr, exitCode } = run(__dirname, ['--stats=verbose', '--config=stats-string.webpack.config.js']); | ||
const { stdout, exitCode } = run(__dirname, ['--stats=verbose', '--config=stats-string.webpack.config.js']); | ||
|
||
const output = isWebpack5 ? '<i> [webpack-cli] output:' : 'main.js'; | ||
expect(stderr).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); | ||
const output = 'main.js'; | ||
expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); | ||
expect(exitCode).toBe(0); | ||
}); | ||
|
||
it('should work with the "stats" option from the configuration', () => { | ||
const { stderr, exitCode } = run(__dirname, ['--config=stats-string.webpack.config.js']); | ||
const { stdout, exitCode } = run(__dirname, ['--config=stats-string.webpack.config.js']); | ||
|
||
const output = isWebpack5 ? '<i> [webpack-cli] output:' : 'main.js'; | ||
expect(stderr).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); | ||
const output = 'main.js'; | ||
expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); | ||
expect(exitCode).toBe(0); | ||
}); | ||
|
||
it('should work with the "stats" option from the configuration #1', () => { | ||
const { stderr, exitCode } = run(__dirname, ['--config=stats-boolean.webpack.config.js']); | ||
const { stdout, exitCode } = run(__dirname, ['--config=stats-boolean.webpack.config.js']); | ||
|
||
const output = isWebpack5 ? '<i> [webpack-cli] output:' : 'main.js'; | ||
expect(stderr).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); | ||
const output = 'main.js'; | ||
expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); | ||
expect(exitCode).toBe(0); | ||
}); | ||
|
||
it('should work with the "stats" option from the configuration #2', () => { | ||
const { stderr, exitCode } = run(__dirname, ['--config=no-stats.webpack.config.js']); | ||
const { stdout, exitCode } = run(__dirname, ['--config=no-stats.webpack.config.js']); | ||
|
||
const output = isWebpack5 ? '<i> [webpack-cli] output:' : 'main.js'; | ||
expect(stderr).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); | ||
const output = 'main.js'; | ||
expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); | ||
expect(exitCode).toBe(0); | ||
}); | ||
|
||
it('should work with the "stats" option from the configuration #3', () => { | ||
const { stderr, exitCode } = run(__dirname, ['--config=colors-true.webpack.config.js']); | ||
const { stdout, exitCode } = run(__dirname, ['--config=colors-true.webpack.config.js']); | ||
|
||
const output = isWebpack5 ? '<i> [webpack-cli] output:' : 'main.js'; | ||
expect(stderr).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); | ||
const output = 'main.js'; | ||
expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); | ||
expect(exitCode).toBe(0); | ||
}); | ||
|
||
it('should work with the "stats" option from the configuration #4', () => { | ||
const { stderr, exitCode } = run(__dirname, ['--config=colors-false.webpack.config.js']); | ||
const { stdout, exitCode } = run(__dirname, ['--config=colors-false.webpack.config.js']); | ||
|
||
const output = isWebpack5 ? '<i> [webpack-cli] output:' : 'main.js'; | ||
const output = 'main.js'; | ||
|
||
expect(stderr).not.toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); | ||
expect(stderr).toContain(output); | ||
expect(stdout).not.toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); | ||
expect(stdout).toContain(output); | ||
expect(exitCode).toBe(0); | ||
}); | ||
}); |
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.