15
15
16
16
require ( "shelljs/make" ) ;
17
17
18
- var checker = require ( "npm-license" ) ,
18
+ const checker = require ( "npm-license" ) ,
19
19
nodeCLI = require ( "shelljs-nodecli" ) ;
20
20
21
21
//------------------------------------------------------------------------------
22
22
// Settings
23
23
//------------------------------------------------------------------------------
24
24
25
- var OPEN_SOURCE_LICENSES = [
25
+ const OPEN_SOURCE_LICENSES = [
26
26
/ M I T / , / B S D / , / A p a c h e / , / I S C / , / W T F / , / P u b l i c D o m a i n /
27
27
] ;
28
28
29
29
//------------------------------------------------------------------------------
30
30
// Data
31
31
//------------------------------------------------------------------------------
32
32
33
- var NODE_MODULES = "./node_modules/" ,
33
+ const NODE_MODULES = "./node_modules/" ,
34
34
35
35
// Utilities - intentional extra space at the end of each string
36
- MOCHA = NODE_MODULES + " mocha/bin/_mocha " ,
36
+ MOCHA = ` ${ NODE_MODULES } mocha/bin/_mocha ` ,
37
37
38
38
// Files
39
39
MAKEFILE = "./Makefile.js" ,
40
40
/* eslint-disable no-use-before-define */
41
- JS_FILES = find ( "lib/" ) . filter ( fileType ( "js" ) ) . join ( " " ) + " parser.js" ,
41
+ JS_FILES = ` ${ find ( "lib/" ) . filter ( fileType ( "js" ) ) . join ( " " ) } parser.js` ,
42
42
TEST_FILES = find ( "tests/lib/" ) . filter ( fileType ( "js" ) ) . join ( " " ) ;
43
43
/* eslint-enable no-use-before-define */
44
44
@@ -67,7 +67,7 @@ target.all = function() {
67
67
} ;
68
68
69
69
target . lint = function ( ) {
70
- var errors = 0 ,
70
+ let errors = 0 ,
71
71
lastReturn ;
72
72
73
73
echo ( "Validating Makefile.js" ) ;
@@ -96,10 +96,8 @@ target.lint = function() {
96
96
target . test = function ( ) {
97
97
target . lint ( ) ;
98
98
99
- var errors = 0 ,
100
- lastReturn ;
101
-
102
- lastReturn = nodeCLI . exec ( "istanbul" , "cover" , MOCHA , "-- -c" , TEST_FILES ) ;
99
+ const lastReturn = nodeCLI . exec ( "istanbul" , "cover" , MOCHA , "-- -c" , TEST_FILES ) ;
100
+ let errors = 0 ;
103
101
104
102
if ( lastReturn . code !== 0 ) {
105
103
errors ++ ;
@@ -122,42 +120,34 @@ target.checkLicenses = function() {
122
120
123
121
/**
124
122
* Returns true if the given dependency's licenses are all permissable for use in OSS
125
- * @param {object } dependency object containing the name and licenses of the given dependency
123
+ * @param {Object } dependency object containing the name and licenses of the given dependency
126
124
* @returns {boolean } is permissable dependency
127
125
*/
128
126
function isPermissible ( dependency ) {
129
- var licenses = dependency . licenses ;
127
+ const licenses = dependency . licenses ;
130
128
131
129
if ( Array . isArray ( licenses ) ) {
132
- return licenses . some ( function ( license ) {
133
- return isPermissible ( {
134
- name : dependency . name ,
135
- licenses : license
136
- } ) ;
137
- } ) ;
130
+ return licenses . some ( license => isPermissible ( {
131
+ name : dependency . name ,
132
+ licenses : license
133
+ } ) ) ;
138
134
}
139
135
140
- return OPEN_SOURCE_LICENSES . some ( function ( license ) {
141
- return license . test ( licenses ) ;
142
- } ) ;
136
+ return OPEN_SOURCE_LICENSES . some ( license => license . test ( licenses ) ) ;
143
137
}
144
138
145
139
echo ( "Validating licenses" ) ;
146
140
147
141
checker . init ( {
148
142
start : __dirname
149
- } , function ( deps ) {
150
- var impermissible = Object . keys ( deps ) . map ( function ( dependency ) {
151
- return {
152
- name : dependency ,
153
- licenses : deps [ dependency ] . licenses
154
- } ;
155
- } ) . filter ( function ( dependency ) {
156
- return ! isPermissible ( dependency ) ;
157
- } ) ;
143
+ } , deps => {
144
+ const impermissible = Object . keys ( deps ) . map ( dependency => ( {
145
+ name : dependency ,
146
+ licenses : deps [ dependency ] . licenses
147
+ } ) ) . filter ( dependency => ! isPermissible ( dependency ) ) ;
158
148
159
149
if ( impermissible . length ) {
160
- impermissible . forEach ( function ( dependency ) {
150
+ impermissible . forEach ( dependency => {
161
151
console . error ( "%s license for %s is impermissible." ,
162
152
dependency . licenses ,
163
153
dependency . name
0 commit comments