Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
zxdong262 committed Jun 4, 2022
1 parent 4954ce2 commit 8a7a002
Show file tree
Hide file tree
Showing 4 changed files with 8,946 additions and 157 deletions.
2 changes: 2 additions & 0 deletions bin/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const copy = require('json-deep-copy')
const stylus = require('stylus')
const { exec } = require('shelljs')
const giteeBuild = require('./rebuild-gitee')
const urlFix = require('../bin/url-fix')

function createData () {
const localeFolder = resolve(__dirname, '../node_modules/@electerm/electerm-locales/dist')
Expand Down Expand Up @@ -142,6 +143,7 @@ async function build () {
const fo = resolve(__dirname, '../../electerm')
await exec(`cd ${fo} && git co gh-pages && cp -rf ../electerm.html5beta.com/data ./ && cp ../electerm.html5beta.com/*.html ./ && git add --all && git commit -m 'update' && git push && git push gt gh-pages`)
await exec(`cd ${fo} && git fetch origin master:master && git push gt master:master`)
urlFix()
giteeBuild()
}

Expand Down
41 changes: 41 additions & 0 deletions bin/url-fix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const { readdirSync } = require('fs')
const { resolve } = require('path')
const replace = require('replace-in-file')

function fix (name, folder) {
const p = resolve(folder, name)
const options = {
files: [p],
from: /href="\/electerm\//g,
to: 'href="/'
}
const options1 = {
files: [p],
from: 'href="/electerm"',
to: 'href="/"'
}
replace(options)
.then(() => {
return replace(options1)
})
.then(() => {
console.log('[INFO] Successfully fix', p)
})
.catch(e => {
console.error('[ERR] Error fix', p)
console.error(e)
process.exit(1)
})
}

function main () {
const p = resolve(__dirname, '..')
const all = readdirSync(p).filter(p => p.startsWith('index'))
for (const n of all) {
fix(n, p)
}
}

module.exports = main

// main()

0 comments on commit 8a7a002

Please sign in to comment.