File tree Expand file tree Collapse file tree 5 files changed +56
-0
lines changed Expand file tree Collapse file tree 5 files changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ var ExtractedModule = require("./ExtractedModule");
9
9
var Chunk = require ( "webpack/lib/Chunk" ) ;
10
10
var OrderUndefinedError = require ( "./OrderUndefinedError" ) ;
11
11
var loaderUtils = require ( "loader-utils" ) ;
12
+ var schemaTester = require ( './schema/valid' ) ;
12
13
13
14
var NS = fs . realpathSync ( __dirname ) ;
14
15
@@ -104,6 +105,7 @@ function getOrder(a, b) {
104
105
}
105
106
106
107
function ExtractTextPlugin ( options ) {
108
+ schemaTester ( options ) ;
107
109
if ( arguments . length > 1 ) {
108
110
throw new Error ( "Breaking change: ExtractTextPlugin now only takes a single argument. Either an options " +
109
111
"object *or* the name of the result file.\n" +
Original file line number Diff line number Diff line change 12
12
"webpack-sources" : " ^0.1.0"
13
13
},
14
14
"devDependencies" : {
15
+ "ajv" : " ^4.11.2" ,
15
16
"codecov.io" : " ^0.1.2" ,
16
17
"coveralls" : " ^2.11.2" ,
17
18
"css-loader" : " ^0.21.0" ,
Original file line number Diff line number Diff line change
1
+ {
2
+ "$schema" : " http://json-schema.org/draft-04/schema#" ,
3
+ "type" : " object" ,
4
+ "properties" : {
5
+ "allChunks" : {
6
+ "description" : " " ,
7
+ "type" : " boolean"
8
+ },
9
+ "disable" : {
10
+ "description" : " " ,
11
+ "type" : " boolean"
12
+ },
13
+ "fallbackLoader" : {
14
+ "description" : " A loader that webpack can fall back to if the original one fails." ,
15
+ "type" : " string"
16
+ },
17
+ "filename" : {
18
+ "description" : " The filename and path that ExtractTextPlugin will extract to." ,
19
+ "type" : " string"
20
+ },
21
+ "loader" : {
22
+ "description" : " The loader that ExtractTextPlugin will attempt to load through." ,
23
+ "type" : " string"
24
+ },
25
+ "publicPath" : {
26
+ "description" : " " ,
27
+ "type" : " string"
28
+ }
29
+ },
30
+ "required" : [" loader" ]
31
+ }
Original file line number Diff line number Diff line change
1
+ var Ajv = require ( 'ajv' ) ;
2
+ var ajv = new Ajv ( { allErrors : true } ) ;
3
+ var json = require ( './schema.json' ) ;
4
+
5
+ module . exports = function validate ( data ) {
6
+ var validSchema = ajv . compile ( json ) ;
7
+ var valid = validSchema ( data ) ;
8
+
9
+ if ( ! valid ) {
10
+ throw new Error ( "Your ExtractTextPlugin config is not correct. Please double check." ) ;
11
+ } else {
12
+ console . log ( 'your stuff works' ) ;
13
+ }
14
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "allChunks" : { "type" : " boolean" },
3
+ "disable" : { "type" : " boolean" },
4
+ "fallbackLoader" : { "type" : " string" },
5
+ "filename" : { "type" : " string" },
6
+ "loader" : { "type" : " string" },
7
+ "publicPath" : { "type" : " string" }
8
+ }
You can’t perform that action at this time.
0 commit comments