-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostbuild.js
37 lines (31 loc) · 919 Bytes
/
postbuild.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
#!/usr/bin/env node
/* eslint-disable no-console */
/*!
* equk-gatsby-postbuild v1.0.0
*
* Copyright (c) 2020 B.Walden. All rights reserved.
*
* Licensed under the MIT License
*
* (LICENSE file should be included with script)
*
*/
const fs = require('fs')
const publicFolder = `${__dirname}/public/`
const outFile = `${__dirname}/public/admin/cms.css`
if (!fs.existsSync(publicFolder)) {
console.log(`ERROR: posts folder not found: ${publicFolder}`)
process.exit(1)
}
const css = fs.readdirSync(publicFolder).filter((fn) => fn.endsWith('.css'))
if (css.length === 1) {
console.log(`INFO: copying ${publicFolder + css[0]} to ${outFile}`)
fs.copyFile(publicFolder + css[0], outFile, (err) => {
if (err) throw err
console.log(`${publicFolder + css[0]} was copied to ${outFile}`)
})
} else {
console.log(`ERROR: ${css.length} files found expected 1`)
process.exit(1)
}
process.exit(0)