-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.js
43 lines (38 loc) · 1.39 KB
/
release.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
const fs = require('fs')
const zipdir = require('zip-a-folder').zip
const pkg = require('./package.json')
const today = new Date()
today.setHours(12, 0, 0, 0)
const isoToday = today.toISOString().split('T')[0]
const banner = `/*!
*
* ${pkg.name} v${pkg.version} (${isoToday})
* ${pkg.homepage}
* @license ${pkg.license}
*
*/
`
const htmlBanner = `<title>accessible-event-calendar</title>
<!--
${pkg.name} v${pkg.version} (${isoToday})
${pkg.homepage}
@license ${pkg.license}
-->`
const data = fs.readdirSync('./dist/').forEach(fileName => {
if (/.min.js$/.test(fileName)) {
const js = fs.readFileSync(`./dist/${fileName}`, {encoding:'utf8'})
fs.writeFileSync(`./dist/${fileName}`, `${js}\n${banner}`)
} else if (/.js$/.test(fileName)) {
const js = fs.readFileSync(`./dist/${fileName}`, {encoding:'utf8'})
fs.writeFileSync(`./dist/${fileName}`, `${banner}${js}`)
} else if (/.css$/.test(fileName)) {
const css = fs.readFileSync(`./dist/${fileName}`, {encoding:'utf8'})
fs.writeFileSync(`./dist/${fileName}`, `${banner}${css}`)
} else if (/.html$/.test(fileName)) {
const html = fs.readFileSync(`./dist/${fileName}`, {encoding:'utf8'})
fs.writeFileSync(`./dist/${fileName}`, html.replace(/\<title\>accessible-event-calendar\<\/title\>/, htmlBanner))
}
})
zipdir('./dist', `./accessible-event-calendar-v${pkg.version}.zip`, (err, buffer) => {
throw err
})