-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepareElectronProd.js
22 lines (18 loc) · 864 Bytes
/
prepareElectronProd.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const {readFile, writeFile, copy} = require('fs-extra');
const homepage = require('./package.json').homepage;
const version = require('./package.json').version;
const repository = require('./package.json').repository;
const inputIndexPath = `${__dirname}/app/electronIndex.html`;
const outputIndexPath = `${__dirname}/app/electronIndex.html`;
let fixed;
let fixed404;
readFile(inputIndexPath, 'utf8')
.then(str => {
fixed = str
.replace(/="\//g, `="${homepage}/`)
.replace(/window.__PUBLIC_URL__ = '[^']*';/g, `window.__PUBLIC_URL__ = '${homepage}';`)
.replace(/window.__DICTO_VERSION__ = '[^']*';/g, `window.__DICTO_VERSION__ = '${version}';`)
.replace(/window.__SOURCE_REPOSITORY__ = '[^']*';/g, `window.__SOURCE_REPOSITORY__ = '${repository}';`)
return writeFile(outputIndexPath, fixed, 'utf8')
})
.catch(console.error)