-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpack.js
More file actions
45 lines (38 loc) · 935 Bytes
/
pack.js
File metadata and controls
45 lines (38 loc) · 935 Bytes
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
const fs = require('fs')
const archiver = require('archiver')
const outputPath = './dist/orchestra-pdf.zip'
const filesToPack = [
'.ebextensions/chromiumpackages.config',
'.npmrc',
'index.js',
'package-lock.json',
'package.json',
'pdf.js',
]
// Make sure dist folder exists
if (!fs.existsSync('./dist')) {
fs.mkdirSync('./dist')
}
// Delete existing package
if (fs.existsSync(outputPath)) {
fs.unlinkSync(outputPath)
}
// Create output stream and archive
const output = fs.createWriteStream(outputPath)
const archive = archiver('zip', {
gzip: true,
zlib: { level: 9 }
})
// Error handling
archive.on('error', err => {
throw err
})
// Package files into archive
archive.pipe(output)
console.log('📦 Start packing up files')
filesToPack.forEach(file => {
archive.file('./' + file, { name: file })
console.log(`--- ${file}`)
})
archive.finalize()
console.log('✅ Finished!')