File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ const targetList = new Set ( [
2+ "acorn" ,
3+ "babel" ,
4+ "babylon" ,
5+ "buble" ,
6+ "chai" ,
7+ "coffeescript" ,
8+ "espree" ,
9+ "esprima" ,
10+ "jshint" ,
11+ "lebab" ,
12+ "prepack" ,
13+ "prettier" ,
14+ "source-map" ,
15+ "typescript" ,
16+ "uglify-es" ,
17+ "uglify-js"
18+ ] ) ;
19+
20+ function getOnlyFlag ( argv ) {
21+ if ( process . argv . indexOf ( "--only" ) != - 1 ) {
22+ return process . argv [ process . argv . indexOf ( "--only" ) + 1 ] ;
23+ }
24+ }
25+
26+ module . exports = {
27+ getTarget : function ( ) {
28+ let onlyArg = getOnlyFlag ( ) ;
29+ if ( targetList . has ( onlyArg ) ) {
30+ return [ onlyArg ] ;
31+ } else if ( typeof ONLY != "undefined" && targetList . has ( ONLY ) ) {
32+ return [ ONLY ] ;
33+ } else {
34+ return [ ...targetList ] ;
35+ }
36+ } ,
37+ targetList : targetList
38+ } ;
Original file line number Diff line number Diff line change 33// found in the LICENSE file.
44
55const Benchmark = require ( "benchmark" ) ;
6+ const getTarget = require ( "./cli-flags-helper" ) . getTarget ;
67
78// We need to run deterministically, so we set 'maxTime' to 0, which
89// disables the variable iteration count feature of benchmark.js,
@@ -14,34 +15,12 @@ const defaultOptions = {
1415 minSamples : 20
1516} ;
1617
17- const targetList = [
18- "acorn" ,
19- "babel" ,
20- "babylon" ,
21- "buble" ,
22- "chai" ,
23- "coffeescript" ,
24- "espree" ,
25- "esprima" ,
26- "jshint" ,
27- "lebab" ,
28- "prepack" ,
29- "prettier" ,
30- "source-map" ,
31- "typescript" ,
32- "uglify-es" ,
33- "uglify-js"
34- ] ;
35-
3618const suite = new Benchmark . Suite ( ) ;
37- const targetItems = ONLY ? [ ONLY ] : null ;
38-
39- const requireList = ( targetItems || targetList ) . map ( val => {
40- return require ( `./${ val } -benchmark` ) ;
41- } ) ;
4219
43- requireList . forEach ( options => {
44- suite . add ( Object . assign ( { } , options , defaultOptions ) ) ;
20+ getTarget ( ) . forEach ( target => {
21+ suite . add (
22+ Object . assign ( { } , require ( `./${ target } -benchmark` ) , defaultOptions )
23+ ) ;
4524} ) ;
4625
4726module . exports = suite ;
Original file line number Diff line number Diff line change @@ -6,34 +6,10 @@ const CopyWebpackPlugin = require("copy-webpack-plugin");
66const HtmlWebpackPlugin = require ( "html-webpack-plugin" ) ;
77const path = require ( "path" ) ;
88const webpack = require ( "webpack" ) ;
9-
10- const targetList = [
11- "acorn" ,
12- "babel" ,
13- "babylon" ,
14- "buble" ,
15- "chai" ,
16- "coffeescript" ,
17- "espree" ,
18- "esprima" ,
19- "jshint" ,
20- "lebab" ,
21- "prepack" ,
22- "prettier" ,
23- "source-map" ,
24- "typescript" ,
25- "uglify-es" ,
26- "uglify-js"
27- ] ;
9+ const targetList = require ( "./src/cli-flags-helper" ) . targetList ;
2810
2911function getTarget ( env ) {
30- return (
31- env &&
32- env . only &&
33- targetList . find ( elem => {
34- return elem == env . only ;
35- } )
36- ) ;
12+ return env && targetList . has ( env . only ) && env . only ;
3713}
3814
3915module . exports = env => [
You can’t perform that action at this time.
0 commit comments