1
- var path = require ( 'path' ) ,
2
- fs = require ( 'fs' ) ;
1
+ const path = require ( 'path' ) ;
2
+ const fs = require ( 'fs' ) ;
3
3
4
4
exports = module . exports = Command ;
5
5
6
- var subCommands = {
6
+ const subCommands = {
7
7
init : {
8
8
description : 'initialize jasmine' ,
9
9
action : initJasmine
@@ -28,14 +28,14 @@ function Command(projectBaseDir, examplesDir, print) {
28
28
this . projectBaseDir = projectBaseDir ;
29
29
this . specDir = path . join ( projectBaseDir , 'spec' ) ;
30
30
31
- var command = this ;
31
+ const command = this ;
32
32
33
33
this . run = function ( jasmine , commands ) {
34
34
setEnvironmentVariables ( commands ) ;
35
35
36
- var commandToRun ;
36
+ let commandToRun ;
37
37
Object . keys ( subCommands ) . forEach ( function ( cmd ) {
38
- var commandObject = subCommands [ cmd ] ;
38
+ const commandObject = subCommands [ cmd ] ;
39
39
if ( commands . indexOf ( cmd ) >= 0 ) {
40
40
commandToRun = commandObject ;
41
41
} else if ( commandObject . alias && commands . indexOf ( commandObject . alias ) >= 0 ) {
@@ -46,7 +46,7 @@ function Command(projectBaseDir, examplesDir, print) {
46
46
if ( commandToRun ) {
47
47
commandToRun . action ( { jasmine : jasmine , projectBaseDir : command . projectBaseDir , specDir : command . specDir , examplesDir : examplesDir , print : print } ) ;
48
48
} else {
49
- var env = parseOptions ( commands ) ;
49
+ const env = parseOptions ( commands ) ;
50
50
if ( env . unknownOptions . length > 0 ) {
51
51
process . exitCode = 1 ;
52
52
print ( 'Unknown options: ' + env . unknownOptions . join ( ', ' ) ) ;
@@ -64,7 +64,7 @@ function isFileArg(arg) {
64
64
}
65
65
66
66
function parseOptions ( argv ) {
67
- var files = [ ] ,
67
+ let files = [ ] ,
68
68
helpers = [ ] ,
69
69
requires = [ ] ,
70
70
unknownOptions = [ ] ,
@@ -77,8 +77,8 @@ function parseOptions(argv) {
77
77
random ,
78
78
seed ;
79
79
80
- for ( var i in argv ) {
81
- var arg = argv [ i ] ;
80
+ for ( let i in argv ) {
81
+ const arg = argv [ i ] ;
82
82
if ( arg === '--no-color' ) {
83
83
color = false ;
84
84
} else if ( arg === '--color' ) {
@@ -126,7 +126,7 @@ function parseOptions(argv) {
126
126
}
127
127
128
128
function runJasmine ( jasmine , env , print ) {
129
- var loadConfig = require ( './loadConfig' ) ;
129
+ const loadConfig = require ( './loadConfig' ) ;
130
130
loadConfig ( jasmine , env , print ) ;
131
131
jasmine . execute ( env . files , env . filter )
132
132
. catch ( function ( error ) {
@@ -136,8 +136,8 @@ function runJasmine(jasmine, env, print) {
136
136
}
137
137
138
138
function initJasmine ( options ) {
139
- var print = options . print ;
140
- var specDir = options . specDir ;
139
+ const print = options . print ;
140
+ const specDir = options . specDir ;
141
141
makeDirStructure ( path . join ( specDir , 'support/' ) ) ;
142
142
if ( ! fs . existsSync ( path . join ( specDir , 'support/jasmine.json' ) ) ) {
143
143
fs . writeFileSync ( path . join ( specDir , 'support/jasmine.json' ) , fs . readFileSync ( path . join ( __dirname , '../lib/examples/jasmine.json' ) , 'utf-8' ) ) ;
@@ -148,9 +148,9 @@ function initJasmine(options) {
148
148
}
149
149
150
150
function installExamples ( options ) {
151
- var specDir = options . specDir ;
152
- var projectBaseDir = options . projectBaseDir ;
153
- var examplesDir = options . examplesDir ;
151
+ const specDir = options . specDir ;
152
+ const projectBaseDir = options . projectBaseDir ;
153
+ const examplesDir = options . examplesDir ;
154
154
155
155
makeDirStructure ( path . join ( specDir , 'support' ) ) ;
156
156
makeDirStructure ( path . join ( specDir , 'jasmine_examples' ) ) ;
@@ -177,12 +177,12 @@ function installExamples(options) {
177
177
}
178
178
179
179
function help ( options ) {
180
- var print = options . print ;
180
+ const print = options . print ;
181
181
print ( 'Usage: jasmine [command] [options] [files] [--]' ) ;
182
182
print ( '' ) ;
183
183
print ( 'Commands:' ) ;
184
184
Object . keys ( subCommands ) . forEach ( function ( cmd ) {
185
- var commandNameText = cmd ;
185
+ let commandNameText = cmd ;
186
186
if ( subCommands [ cmd ] . alias ) {
187
187
commandNameText = commandNameText + ',' + subCommands [ cmd ] . alias ;
188
188
}
@@ -210,7 +210,7 @@ function help(options) {
210
210
}
211
211
212
212
function version ( options ) {
213
- var print = options . print ;
213
+ const print = options . print ;
214
214
print ( 'jasmine v' + require ( '../package.json' ) . version ) ;
215
215
print ( 'jasmine-core v' + options . jasmine . coreVersion ( ) ) ;
216
216
}
@@ -224,7 +224,7 @@ function lPad(str, length) {
224
224
}
225
225
226
226
function copyFiles ( srcDir , destDir , pattern ) {
227
- var srcDirFiles = fs . readdirSync ( srcDir ) ;
227
+ const srcDirFiles = fs . readdirSync ( srcDir ) ;
228
228
srcDirFiles . forEach ( function ( file ) {
229
229
if ( file . search ( pattern ) !== - 1 ) {
230
230
fs . writeFileSync ( path . join ( destDir , file ) , fs . readFileSync ( path . join ( srcDir , file ) ) ) ;
@@ -233,10 +233,10 @@ function copyFiles(srcDir, destDir, pattern) {
233
233
}
234
234
235
235
function makeDirStructure ( absolutePath ) {
236
- var splitPath = absolutePath . split ( path . sep ) ;
236
+ const splitPath = absolutePath . split ( path . sep ) ;
237
237
splitPath . forEach ( function ( dir , index ) {
238
238
if ( index > 1 ) {
239
- var fullPath = path . join ( splitPath . slice ( 0 , index ) . join ( '/' ) , dir ) ;
239
+ const fullPath = path . join ( splitPath . slice ( 0 , index ) . join ( '/' ) , dir ) ;
240
240
if ( ! fs . existsSync ( fullPath ) ) {
241
241
fs . mkdirSync ( fullPath ) ;
242
242
}
@@ -245,16 +245,16 @@ function makeDirStructure(absolutePath) {
245
245
}
246
246
247
247
function isEnvironmentVariable ( command ) {
248
- var envRegExp = / ( .* ) = ( .* ) / ;
248
+ const envRegExp = / ( .* ) = ( .* ) / ;
249
249
return command . match ( envRegExp ) ;
250
250
}
251
251
252
252
function setEnvironmentVariables ( commands ) {
253
253
commands . forEach ( function ( command ) {
254
- var regExpMatch = isEnvironmentVariable ( command ) ;
254
+ const regExpMatch = isEnvironmentVariable ( command ) ;
255
255
if ( regExpMatch ) {
256
- var key = regExpMatch [ 1 ] ;
257
- var value = regExpMatch [ 2 ] ;
256
+ const key = regExpMatch [ 1 ] ;
257
+ const value = regExpMatch [ 2 ] ;
258
258
process . env [ key ] = value ;
259
259
}
260
260
} ) ;
0 commit comments