Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
fix: fix gh pages
Browse files Browse the repository at this point in the history
  • Loading branch information
farism committed Dec 4, 2019
1 parent 61dae4d commit 8704f22
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 30 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"execa": "3.4.0",
"fs-extra": "8.1.0",
"husky": "3.1.0",
"lerna": "3.19.0"
"lerna": "3.19.0",
"mkdirp": "^0.5.1"
}
}
64 changes: 35 additions & 29 deletions scripts/deploy-gh-pages.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,38 @@
const { sync } = require('execa')
const mkdirp = require('mkdirp')
const path = require('path')
const { exec } = require('execa-pro')

const { version } = require('../lerna.json')
; (async () => {
const target = process.argv.slice(2)[0]
const remote = sync('git', ['config', 'remote.origin.url']).stdout

const cwd = path.join(process.cwd(), 'tmp/gh-pages')
;(async () => {
const target = process.argv.slice(2)[0]
const remote = await exec('git config remote.origin.url')
await exec(`mkdirp ${cwd}`)
await exec(
[
`git init`,
`git remote add --fetch origin ${remote[0].stdout}`,
`git checkout -b gh-pages`,
`git checkout gh-pages`,
`rm -rf ${target || 'latest'}`,
`mkdirp v`,
`cp -r ../../packages/docs/build ${target || `v/${version}`}`,
`cp -r ../../packages/docs/build ${target || 'latest'}`,
`cp -r ../../packages/docs/build/404.html 404.html`,
`git add --all`,
`git commit --allow-empty -m gh-pages`,
`git push --force --quiet origin gh-pages`,
],
{
cwd,
stdio: 'inherit',
reject: false,
}
)
})()
const { version } = require('../lerna.json')
const cwd = path.join(process.cwd(), 'tmp/gh-pages')
mkdirp.sync(cwd)

const commands =
[
`git init`,
`git remote add --fetch origin ${remote[0].stdout}`,
`git checkout -b gh-pages`,
`git checkout gh-pages`,
`rm -rf ${target || 'latest'}`,
`mkdirp v`,
`cp -r ../../packages/docs/build ${target || `v/${version}`}`,
`cp -r ../../packages/docs/build ${target || 'latest'}`,
`cp -r ../../packages/docs/build/404.html 404.html`,
`git add --all`,
`git commit --allow-empty -m gh-pages`,
`git push --force --quiet origin gh-pages`,
]

commands.forEach(cmd => {
const c = cmd.split(' ')

sync(c[0], c.slice(1), {
cwd,
stdio: 'inherit',
reject: false,
})
})
})()

0 comments on commit 8704f22

Please sign in to comment.