File tree Expand file tree Collapse file tree 3 files changed +45
-52
lines changed Expand file tree Collapse file tree 3 files changed +45
-52
lines changed 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 3
3
// found in the LICENSE file.
4
4
5
5
const Benchmark = require ( "benchmark" ) ;
6
+ const getTarget = require ( "./cli-flags-helper" ) . getTarget ;
6
7
7
8
// We need to run deterministically, so we set 'maxTime' to 0, which
8
9
// disables the variable iteration count feature of benchmark.js,
@@ -14,34 +15,12 @@ const defaultOptions = {
14
15
minSamples : 20
15
16
} ;
16
17
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
-
36
18
const suite = new Benchmark . Suite ( ) ;
37
- const targetItems = ONLY ? [ ONLY ] : null ;
38
-
39
- const requireList = ( targetItems || targetList ) . map ( val => {
40
- return require ( `./${ val } -benchmark` ) ;
41
- } ) ;
42
19
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
+ ) ;
45
24
} ) ;
46
25
47
26
module . exports = suite ;
Original file line number Diff line number Diff line change @@ -6,34 +6,10 @@ const CopyWebpackPlugin = require("copy-webpack-plugin");
6
6
const HtmlWebpackPlugin = require ( "html-webpack-plugin" ) ;
7
7
const path = require ( "path" ) ;
8
8
const 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 ;
28
10
29
11
function 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 ;
37
13
}
38
14
39
15
module . exports = env => [
You can’t perform that action at this time.
0 commit comments