-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwriting.js
117 lines (100 loc) · 3.08 KB
/
writing.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';
var _ = require('lodash');
var path = require('path');
var mkdirp = require('mkdirp');
module.exports = function () {
var props = this.props;
var destPath = this.destinationPath();
props._ = {
kebabCase: _.kebabCase,
camelCase: _.camelCase,
capitalize: _.capitalize
};
// create directories
mkdirp(path.join(destPath, 'src/fonts'));
mkdirp(path.join(destPath, 'src/img'));
// dotfiles
this.copy('gitignore', '.gitignore');
this.copy('editorconfig', '.editorconfig');
this.copy('eslintrc', '.eslintrc');
this.copy('gulpfile.js');
this.copy('README.md');
this.template('package.json', props);
// gulp configs
this.copy('gulp/config.js');
this.bulkDirectory('gulp/util', 'gulp/util');
// common tasks
this.template('gulp/tasks/default.js');
this.template('gulp/tasks/build.js', props);
this.template('gulp/tasks/watch.js', props);
this.template('gulp/tasks/copy.js', props);
this.copy('gulp/tasks/clean.js');
this.copy('gulp/tasks/server.js');
this.copy('gulp/tasks/sass.js');
this.bulkDirectory('gulp/tasks/index-page', 'gulp/tasks/index-page');
// compile templates tasks
switch (props.templates) {
case 'nunjucks':
this.copy('gulp/tasks/nunjucks.js');
break;
case 'swig':
this.copy('gulp/tasks/swig.js');
break;
case 'jade':
this.copy('gulp/tasks/jade.js');
break;
}
// image optimization task
if (props.imagemin) {
this.copy('gulp/tasks/imagemin.js');
}
if (props.svgo) {
this.copy('gulp/tasks/svgo.js');
this.directory('src/img/svgo', 'src/img/svgo');
}
if (props.sprites.length) {
this.directory('src/icons', 'src/icons');
}
// iconfont task
if (props.sprites.indexOf('iconfont') !== -1) {
this.bulkDirectory('gulp/tasks/iconfont', 'gulp/tasks/iconfont');
}
// svg sprites task
if (props.sprites.indexOf('svg') !== -1) {
this.bulkDirectory('gulp/tasks/sprite-svg', 'gulp/tasks/sprite-svg');
}
// png sprites task
if (props.sprites.indexOf('png') !== -1) {
this.bulkDirectory('gulp/tasks/sprite-png', 'gulp/tasks/sprite-png');
}
// js bundler task
switch (props.bundler) {
case 'browserify':
this.copy('gulp/tasks/browserify.js');
break;
case 'webpack':
this.bulkCopy('gulp/tasks/webpack.js', 'gulp/tasks/webpack.js');
this.copy('webpack.config.js');
this.copy('babelrc', '.babelrc');
break;
case 'include':
this.copy('gulp/tasks/scripts.js', 'gulp/tasks/scripts.js');
break;
}
// copy directories
this.bundler = props.bundler; // or in /templates/src/js/**/*.js use options.bundler
this.directory('src/js', 'src/js');
this.sprites = props.sprites; // or in /templates/src/sass/app.sass use options.sprites
this.directory('src/sass', 'src/sass');
switch (props.templates) {
case 'nunjucks':
this.directory('src/templates-nunjucks', 'src/templates');
break;
case 'swig':
this.directory('src/templates-swig', 'src/templates');
break;
case 'jade':
this.directory('src/templates-jade', 'src/templates');
break;
}
};