1515
1616require ( "shelljs/make" ) ;
1717
18- var checker = require ( "npm-license" ) ,
18+ const checker = require ( "npm-license" ) ,
1919 nodeCLI = require ( "shelljs-nodecli" ) ;
2020
2121//------------------------------------------------------------------------------
2222// Settings
2323//------------------------------------------------------------------------------
2424
25- var OPEN_SOURCE_LICENSES = [
25+ const OPEN_SOURCE_LICENSES = [
2626 / 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 /
2727] ;
2828
2929//------------------------------------------------------------------------------
3030// Data
3131//------------------------------------------------------------------------------
3232
33- var NODE_MODULES = "./node_modules/" ,
33+ const NODE_MODULES = "./node_modules/" ,
3434
3535 // Utilities - intentional extra space at the end of each string
36- MOCHA = NODE_MODULES + " mocha/bin/_mocha " ,
36+ MOCHA = ` ${ NODE_MODULES } mocha/bin/_mocha ` ,
3737
3838 // Files
3939 MAKEFILE = "./Makefile.js" ,
4040 /* 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` ,
4242 TEST_FILES = find ( "tests/lib/" ) . filter ( fileType ( "js" ) ) . join ( " " ) ;
4343 /* eslint-enable no-use-before-define */
4444
@@ -67,7 +67,7 @@ target.all = function() {
6767} ;
6868
6969target . lint = function ( ) {
70- var errors = 0 ,
70+ let errors = 0 ,
7171 lastReturn ;
7272
7373 echo ( "Validating Makefile.js" ) ;
@@ -96,10 +96,8 @@ target.lint = function() {
9696target . test = function ( ) {
9797 target . lint ( ) ;
9898
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 ;
103101
104102 if ( lastReturn . code !== 0 ) {
105103 errors ++ ;
@@ -122,42 +120,34 @@ target.checkLicenses = function() {
122120
123121 /**
124122 * 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
126124 * @returns {boolean } is permissable dependency
127125 */
128126 function isPermissible ( dependency ) {
129- var licenses = dependency . licenses ;
127+ const licenses = dependency . licenses ;
130128
131129 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+ } ) ) ;
138134 }
139135
140- return OPEN_SOURCE_LICENSES . some ( function ( license ) {
141- return license . test ( licenses ) ;
142- } ) ;
136+ return OPEN_SOURCE_LICENSES . some ( license => license . test ( licenses ) ) ;
143137 }
144138
145139 echo ( "Validating licenses" ) ;
146140
147141 checker . init ( {
148142 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 ) ) ;
158148
159149 if ( impermissible . length ) {
160- impermissible . forEach ( function ( dependency ) {
150+ impermissible . forEach ( dependency => {
161151 console . error ( "%s license for %s is impermissible." ,
162152 dependency . licenses ,
163153 dependency . name
0 commit comments