-
Notifications
You must be signed in to change notification settings - Fork 1
/
make.js
44 lines (36 loc) · 1.07 KB
/
make.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
const fs = require('fs')
const gulpDir = './gulpfile'
const makeList = [
'require.js',
'clean.js',
'html.js',
'css.js',
'js.js',
'image.js',
'resources.js',
'server.js'
]
let fileContent = `/** GulpFile Concat By ./gulpfile/*.js */\n`
function doConcat () {
fs.readdir(gulpDir, function (err, dataList) {
if (err) {
console.error(err)
return
}
dataList
.filter(x => makeList.includes(x))
.sort((a, b) => makeList.indexOf(a) - makeList.indexOf(b))
.reduce((res, taskname) => {
const filePath = gulpDir + '/' + taskname
const status = fs.statSync(filePath)
status.mode == 33206 && res.push(filePath)
return res
}, [])
.map((f, index, handle) => {
let c = fs.readFileSync(f)
fileContent += c.toString() + (index === handle.length - 1 ? '' : '\n\n\n')
})
fs.writeFileSync('./gulpfile.babel.js', fileContent)
})
}
doConcat()