forked from ajbarry3/createjs-module
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.es6.js
More file actions
48 lines (41 loc) · 1.28 KB
/
gulpfile.es6.js
File metadata and controls
48 lines (41 loc) · 1.28 KB
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
import fs from 'fs';
import gulp from 'gulp';
import gutil from 'gulp-util';
import insert from 'gulp-insert';
import concat from 'gulp-concat';
const VERSIONS = {
PRELOAD: '1.0.0',
SOUNDL: '1.0.0',
};
const SRC = {
PRELOAD: `./preloadjs.js`,
SOUND: `./soundjs.js`
};
const DEST = {
CREATE: './'
};
function string_src(filename, string) {
var src = require('stream').Readable({ objectMode: true });
src._read = function () {
this.push(new gutil.File({ cwd: '', base: '', path: filename, contents: new Buffer(string) }));
this.push(null)
};
return src
}
gulp.task('compile', () => {
return gulp.src([
SRC.PRELOAD,
SRC.SOUND
])
.pipe(concat('createjs.js'))
.pipe(insert.prepend('var createjs = (this.createjs = (this.createjs || {}));\n'))
.pipe(insert.append('\nif(typeof module !== "undefined" && typeof module.exports !== "undefined") module.exports = this.createjs;'))
.pipe(gulp.dest(DEST.CREATE));
});
gulp.task('package', () => {
let pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
pkg.version = VERSIONS.CREATE;
return string_src('package.json', JSON.stringify(pkg, null, 4))
.pipe(gulp.dest(DEST.CREATE));
});
gulp.task('default', ['compile', 'package']);