-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
85 lines (76 loc) · 2.23 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
var gulp = require('gulp'),
karma = require('gulp-karma'),
insert = require('gulp-insert'),
rename = require("gulp-rename")
;
gulp.task('test', function() {
var files = [
'bower_components/lodash/dist/lodash.min.js',
'src/collection.js',
'tests/unit/**/*.js'
];
return gulp.src(files)
.pipe(karma({
configFile: 'karma.conf.js',
action: 'run'
}))
.on('error', function(err) {
console.error(err.message);
//throw err;
});
});
gulp.task('test-package-global', function() {
var files = [
'bower_components/lodash/dist/lodash.min.js',
'js-collection.js',
'tests/package/global.js'
];
return gulp.src(files)
.pipe(karma({
configFile: 'karma.conf.js',
action: 'run'
}))
.on('error', function(err) {
console.error(err.message);
});
});
gulp.task('test-package-angular', function() {
var files = [
'bower_components/lodash/dist/lodash.min.js',
'bower_components/angular/angular.js',
'bower_components/angular-mocks/angular-mocks.js',
'angular-js-collection.js',
'tests/package/angular.js'
];
return gulp.src(files)
.pipe(karma({
configFile: 'karma.conf.js',
action: 'run'
}))
.on('error', function(err) {
console.error(err.message);
});
});
gulp.task('test-package', ['test-package-global', 'test-package-angular'], function () {
});
gulp.task('package-global', function () {
return gulp.src('src/collection.js')
.pipe(insert.prepend('(function (window) {'))
.pipe(insert.append('window.JsModel = Model;window.JsCollection = Collection;\n})(window);'))
.pipe(rename('js-collection.js'))
.pipe(gulp.dest('./'))
;
});
gulp.task('package-angular', function () {
return gulp.src('src/collection.js')
.pipe(insert.prepend('(function (angular) {'))
.pipe(insert.append('angular.module(\'JsCollection\', [])'))
.pipe(insert.append('.factory(\'JsModel\', function () { return Model; })'))
.pipe(insert.append('.factory(\'JsCollection\', function () { return Collection; });\n'))
.pipe(insert.append('\n})(angular);'))
.pipe(rename('angular-js-collection.js'))
.pipe(gulp.dest('./'))
;
});
gulp.task('package', ['package-global', 'package-angular'], function () {
});