forked from bemusic/bemuse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
96 lines (88 loc) · 2.19 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
var gulp = require('gulp')
var mocha = require('gulp-mocha')
var cucumber = require('gulp-cucumber')
var fs = require('fs')
var childProcess = require('child_process')
var files = {
specs: ['spec/**/*_spec.js'],
sources: [
'*.js',
'bms/*.js',
'compiler/*.js',
'keysounds/*.js',
'notes/*.js',
'reader/*.js',
'song-info/*.js',
'speedcore/*.js',
'time-signatures/*.js',
'timing/*.js',
'util/*.js',
],
get features() {
var home = process.env.BMSPEC_HOME || './bmspec'
if (home === undefined) {
console.error(
'WARNING! BMSPEC_HOME is not set. BMSpec test suites will not be run!'
)
return []
}
return require('./features').map(function(file) {
var filePath = home + '/features/' + file
if (!fs.existsSync(filePath)) {
console.error('WARNING! ' + filePath + ' does not exist.')
}
return filePath
})
},
}
gulp.task('test', function(callback) {
return mochaThenCucumberTest(callback)
})
gulp.task('test:cucumber', function(callback) {
return cucumberTest(callback)
})
gulp.task('test:mocha', function(callback) {
return mochaTest(callback)
})
gulp.task('bmspec:update', async function() {
if (!fs.existsSync('bmspec')) {
console.log('* Cloning bmspec...')
childProcess.execSync(
`git clone https://github.com/bemusic/bms-spec.git bmspec`,
{
stdio: 'inherit',
}
)
} else {
console.log('* Updating bmspec...')
childProcess.execSync(`git pull`, {
stdio: 'inherit',
})
}
})
function mochaTest(callback) {
global.expect = require('chai').expect
gulp
.src(files.specs, { read: false })
.pipe(mocha({ reporter: 'nyan' }))
.on('end', callback)
.on('error', callback)
}
function cucumberTest(callback) {
gulp
.src(files.features, { read: false })
.pipe(
cucumber({
steps: 'features/step_definitions/**/*_steps.js',
support: ['features/support/world.js', 'features/support/*.js'],
})
)
.on('end', callback)
.on('error', callback)
}
function mochaThenCucumberTest(callback) {
mochaTest(function(error) {
if (error) return callback(error)
cucumberTest(callback)
})
}