-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulp-core.js
60 lines (53 loc) · 1.27 KB
/
gulp-core.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
const gulp = require('gulp');
const gulpif = require('gulp-if');
const intercept = require('gulp-intercept');
const sourcemaps = require('gulp-sourcemaps');
const browserSync = require('browser-sync').create();
const chalk = require('chalk');
const config = require('./gulp.config');
const path = require('path');
const runSequence = require('run-sequence');
const VALID_MODES = ['build', 'start', 'test'];
const DEFAULT_MODE = VALID_MODES[1];
let modeCache;
const getMode = () => {
if (modeCache != null) return modeCache;
modeCache = (process.argv.length > 2) ? process.argv[2] : DEFAULT_MODE;
if (!VALID_MODES.includes(modeCache)) {
modeCache = DEFAULT_MODE;
}
return modeCache;
};
const mainHeading = (taskName, msg) => {
console.log(chalk.bgWhite.black(`${taskName}: ${msg}`));
};
const subHeading = (taskName, msg) => {
taskName = chalk.cyan(taskName);
console.log(`${taskName}: ${msg}`);
};
const link = (url) => {
return chalk.bgCyan.black(url);
};
const serious = (msg) => {
return chalk.bgRed.white(msg);
};
const watch = (msg) => {
return chalk.bgBlue.white(msg);
};
module.exports = {
gulp,
gulpif,
intercept,
sourcemaps,
browserSync,
chalk,
config,
path,
runSequence,
getMode,
mainHeading,
subHeading,
link,
serious,
watch
};