-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathgulpfile.js
76 lines (64 loc) · 2.12 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
const gulp = require('gulp');
const concat = require('gulp-concat');
const uglify = require('gulp-uglify');
const gulpDocs = require('gulp-ngdocs');
const clean = require('gulp-clean');
const rename = require('gulp-rename');
const through = require('through2');
const File = require('vinyl');
var fs = require('fs');
var env = {};
// See if there is an enviromental file with options to override
try {
env = JSON.parse(fs.readFileSync('.env.json').toString());
} catch (e) {}
var target = {
docs: env.docs || './docs'
};
function processScripts () {
return gulp.src('./src/**/*.js')
.pipe(concat('angular-screenfull.js'))
.pipe(gulp.dest('./dist/'))
.pipe(uglify())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('./dist/'));
};
const watch = function() {
gulp.watch('./src/**/*.js', gulp.series(processScripts, ngdocs));
};
exports.watch = watch;
const ngdocs = gulp.series(cleanNgdocs, function ngdocs () {
var options = {
html5Mode: false,
analytics: {
account: 'UA-44454147-3',
domainName: 'http://hrajchert.github.io/angular-screenfull/'
},
scripts: [
'dist/angular-screenfull.js',
'https://cdnjs.cloudflare.com/ajax/libs/screenfull.js/4.0.0/screenfull.js'
]
};
return gulp.src(['./src/**/*.js', './src/**/*.ngdoc'])
.pipe(gulpDocs.process(options))
.pipe(upgradeVynil())
.pipe(gulp.dest(target.docs));
});
/**
* gulp-watch/vinyl-source-stream uses an outdated vinyl, which doesn't have some functions which vinyl-fs expects.
* Can be removed when gulp-watch updates it to vinyl 2.x.
* @returns {NodeJS.ReadWriteStream}
*/
function upgradeVynil() {
return through.obj(function(file, encoding, cb) {
const upgradedFile = new File(file);
cb(null, upgradedFile);
});
}
exports.ngdocs = ngdocs;
function cleanNgdocs() {
return gulp.src(target.docs + '/*', {read:false})
.pipe(clean({force: true}));
}
exports.release = gulp.series(processScripts, ngdocs);
exports.default = gulp.series(processScripts, ngdocs, watch);