-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
71 lines (59 loc) · 1.53 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
'use strict';
let gulp = require('gulp'),
shell = require('gulp-shell'),
connect = require('gulp-connect'),
concat = require('gulp-concat'),
del = require('del'),
srcHTML = './src/*.html',
srcJS = './src/js/**/*.js',
srcC = './src/rom/*.c',
srcROM = './src/rom/*.gb';
gulp.task('clean', () => del('dist/'));
gulp.task('make', function () {
return gulp.src(srcC, {read: false})
.pipe(shell([
'lcc -Wa-l -Wl-m -Wl-j -o <%= f(file.path) %> <%= file.path %>'
], {
templateData: {
f: function (s) {
return s.replace('.c', '.gb')
}
}
}))
.pipe(connect.reload());
});
gulp.task('rom', () => {
return gulp.src(srcROM)
.pipe(gulp.dest('dist/rom/'))
.pipe(connect.reload());
});
gulp.task('html', () => {
return gulp.src(srcHTML)
.pipe(gulp.dest('dist/'))
.pipe(connect.reload());
});
gulp.task('scripts', function() {
return gulp.src(srcJS)
.pipe(concat('game.js'))
.pipe(gulp.dest('./dist/js'))
.pipe(connect.reload());
});
gulp.task('connect', function() {
connect.server({
root: 'dist',
livereload: true
});
});
gulp.task('watch', () => {
let watches = [
[srcC, 'make'],
[srcHTML, 'html'],
[srcROM, 'rom'],
[srcJS, 'js']
];
let onChanged = (event) => console.info(event.path + ' was ' + event.type + '. Running tasks...');
for (let watch of watches) {
gulp.watch(watch[0], [watch[1]]).on('change', onChanged);
}
});
gulp.task('default', [ 'connect', 'make', 'html', 'scripts', 'watch' ]);