forked from xuejianxianzun/PixivBatchDownloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
59 lines (46 loc) · 1.17 KB
/
build.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
// build 命令
const fs = require('fs')
const path = require('path')
const copy = require('recursive-copy')
const archiver = require('archiver')
// 复制一些文件到 dist 目录
async function copys() {
// 复制 static 文件夹的内容
await copy('./static', './dist', {
overwrite: true
}).catch(function(error) {
console.error('Copy failed: ' + error)
})
// 复制静态文件
await copy('./src', './dist', {
overwrite: true,
filter: ['manifest.json']
})
await copy('./', './dist', {
overwrite: true,
filter: ['*.md', 'LICENSE']
})
console.log('Copy success')
// 打包
pack()
}
copys()
// 打包 dist 目录
function pack() {
const zipName = path.resolve(__dirname, 'powerfulpixivdownloader.zip')
const output = fs.createWriteStream(zipName)
const archive = archiver('zip', {
zlib: { level: 9 } // Sets the compression level.
})
archive.on('error', function(err) {
throw err
})
archive.on('finish', () => {
console.log(`Pack success`)
})
// pipe archive data to the file
archive.pipe(output)
// 添加文件夹
archive.directory('dist', 'powerfulpixivdownloader')
archive.finalize()
}