forked from jonnyreeves/js-logger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
64 lines (53 loc) · 1.72 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
var packageJSON = require('./package.json');
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var replace = require('gulp-replace');
var rename = require('gulp-rename');
var qunit = require('gulp-qunit');
var jshint = require('gulp-jshint');
var size = require('gulp-size');
var git = require('gulp-git');
var spawn = require('child_process').spawn;
var version = packageJSON.version;
var srcFile = 'src/logger.js';
gulp.task('src_version', function () {
return gulp.src(srcFile)
.pipe(replace(/VERSION = "[^"]+"/, 'VERSION = "' + version + '"'))
.pipe(gulp.dest('src'));
});
gulp.task('bower_version', function () {
return gulp.src('bower.json')
.pipe(replace(/version": "[^"]+"/, 'version": "' + version + '"'))
.pipe(gulp.dest('.'));
});
gulp.task('version', [ 'src_version', 'bower_version' ]);
gulp.task('lint', [ 'version' ], function () {
return gulp.src([ srcFile, 'test-src/*.js' ])
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(jshint.reporter('fail'));
});
gulp.task('test', [ 'version' ], function () {
return gulp.src('test-src/index.html')
.pipe(qunit());
});
gulp.task('minify', [ 'version' ], function () {
return gulp.src(srcFile)
.pipe(size({ showFiles: true }))
.pipe(uglify())
.pipe(rename('logger.min.js'))
.pipe(size({ showFiles: true }))
.pipe(gulp.dest('src'));
});
gulp.task('release', [ 'push_tag', 'publish_npm' ]);
gulp.task('push_tag', function (done) {
git.tag(version, 'v' + version);
git.push('origin', 'master', {args: " --tags"}, function (err) {
done(err);
});
});
gulp.task('publish_npm', function (done) {
spawn('npm', [ 'publish' ], { stdio: 'inherit' })
.on('close', done);
});
gulp.task('default', [ 'version', 'lint', 'test', 'minify' ]);