This repository has been archived by the owner on Jan 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
117 lines (110 loc) · 2.69 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
'use strict';
/**
*
* @description Gulp configuration file.
* @author
* [{@link https://github.com/apercova|github@apercova}],
* [{@link https://twitter.com/apercova|twitter@apercova}],
* [{@link https://www.npmjs.com/~apercova|npmjs/~apercova}]
*
* @since 1.2.0
*/
const del = require('del'),
gulp = require('gulp'),
eslint = require('gulp-eslint'),
gunzip = require('gulp-gunzip'),
gzip = require('gulp-gzip'),
jsdoc = require('gulp-jsdoc3'),
minify = require('gulp-minify'),
prettierEslint = require('gulp-prettier-eslint'),
tar = require('gulp-tar'),
untar = require('gulp-untar');
/**
* Task for generate docs.
*/
gulp.task('docs', cb => {
del('docs/**');
const config = require('./jsdoc.json');
gulp.src(['README.md', './lib/**/*.js'], { 'read': true }).pipe(jsdoc(config, cb));
});
/**
* Task for backup source files.
*/
gulp.task('source:backup', () => {
return gulp
.src(['**', '!.git/**', '!.docs/**', '!node_modules/**', '!atom-path-intellisense-source.tar.gz'])
.pipe(tar('atom-path-intellisense-source.tar'))
.pipe(gzip())
.pipe(gulp.dest('.'));
});
/**
* Task for prettify source files.
*/
gulp.task('source:prettify', () => {
gulp
.src('lib/**/*.js')
.pipe(prettierEslint())
.pipe(gulp.dest('./lib'));
gulp
.src('spec/**/*.js')
.pipe(prettierEslint())
.pipe(gulp.dest('./spec'));
return gulp
.src('gulpfile.js')
.pipe(prettierEslint())
.pipe(gulp.dest('.'));
});
/**
* Task for lint source files with eslint.
*/
gulp.task('source:lint', () => {
return gulp
.src(['lib/**/*.js', 'spec/**/*.js', 'gulpfile.js', '.eslintrc.json'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
/**
* Task for minify source files.
*/
gulp.task('source:minify', () => {
gulp
.src(['spec/**/*.js'], { 'allowEmpty': true })
.pipe(
minify({
'noSource': true,
'ext': {
'src': '.js',
'min': '.js'
}
})
)
.pipe(gulp.dest('spec/'));
return gulp
.src(['lib/**/*.js'], { 'allowEmpty': true })
.pipe(
minify({
'noSource': true,
'ext': {
'src': '.js',
'min': '.js'
}
})
)
.pipe(gulp.dest('lib/'));
});
/**
* Task for restore source files from tarball.
*/
gulp.task('source:restore', function() {
del(['**', '!.git/**', '!.docs/**', '!node_modules/**', '!atom-path-intellisense-source.tar.gz']);
return gulp
.src('atom-path-intellisense-source.tar.gz')
.pipe(gunzip())
.pipe(untar())
.pipe(gulp.dest('.'));
});
/**
* Task for prepare release artifacts.
*/
gulp.task('release:prepare', gulp.series(['source:lint', 'source:prettify', 'docs']));