This repository has been archived by the owner on Sep 11, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
feat: add JSON reporter. fixes #16 #39
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
36c6c16
feat: add JSON reporter. fixes #16
shellscape fc1a73f
fix: rogress typo
shellscape 4009b56
fix: JsonReporter type
shellscape 6f1b8a5
chore: pretty print json by request
shellscape 655d424
fix: default to stylish for bad reporter names
shellscape File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const weblog = require('webpack-log'); | ||
|
||
const WebpackCommandError = require('../WebpackCommandError'); | ||
|
||
const Reporter = require('./Reporter'); | ||
|
||
module.exports = class JesonReporter extends Reporter { | ||
constructor(...args) { | ||
super(...args); | ||
|
||
const log = weblog({ name: 'webpack', id: 'webpack-command' }); | ||
this.originalLevel = log.level; | ||
log.level = 'silent'; | ||
this.log = log; | ||
} | ||
|
||
/* istanbul ignore next */ | ||
progress() { | ||
throw new WebpackCommandError( | ||
'Build rogress display is not supported when using the JSON reporter' | ||
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. There is a typo here: |
||
); | ||
} | ||
|
||
render(error, stats) { | ||
const json = stats.toJson(); | ||
const result = JSON.stringify(json); | ||
|
||
process.stdout.write(result); | ||
|
||
this.log.level = this.originalLevel; | ||
|
||
return result; | ||
} | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const { resolve } = require('path'); | ||
|
||
const config = require('../../common/webpack.config'); | ||
|
||
module.exports = { | ||
arguments: [], | ||
|
||
config: [ | ||
Object.assign({}, config, { | ||
entry: resolve(__dirname, '../../common/entry-a.js'), | ||
reporter: 'json', | ||
}), | ||
Object.assign({}, config, { | ||
entry: [ | ||
resolve(__dirname, '../../common/entry-b.js'), | ||
resolve(__dirname, '../../common/entry-c.js'), | ||
], | ||
reporter: 'json', | ||
}), | ||
], | ||
|
||
inspect: 'stdout', | ||
|
||
group: 'general', | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const { resolve } = require('path'); | ||
|
||
const config = require('../../common/webpack.config'); | ||
|
||
module.exports = { | ||
arguments: [], | ||
|
||
config: Object.assign({}, config, { | ||
entry: resolve(__dirname, '../../common/entry-a.js'), | ||
reporter: 'json', | ||
}), | ||
|
||
inspect: 'stdout', | ||
|
||
group: 'general', | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// warning | ||
console.log(require); // eslint-disable-line | ||
|
||
// error | ||
if (!window) { require('test'); } // eslint-disable-line | ||
|
||
require('./image.jpg'); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const { resolve } = require('path'); | ||
|
||
const config = require('../../../common/webpack.config'); | ||
|
||
module.exports = { | ||
arguments: [], | ||
|
||
config: Object.assign({}, config, { | ||
entry: resolve(__dirname, './entry-problems.js'), | ||
reporter: 'json', | ||
}), | ||
|
||
inspect: 'stdout', | ||
|
||
group: 'general', | ||
}; |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Should this perhaps be
JsonReporter
instead ofJesonReporter
?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.
jeez, yeah it should. I shouldn't PR so early in the morning 😆
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.
I kinda liked
JesonReporter
😄