Last active
March 26, 2017 18:31
-
-
Save stfsy/d22391e8d135811bcc5fa10aeb43fc06 to your computer and use it in GitHub Desktop.
Quick and dirty pushing to GitHub pages branch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const execSync = require('child_process').execSync | |
const spawnSync = require('child_process').spawnSync | |
const exit = require('process').exit | |
const resolve = require('path').resolve | |
const fs = require('fs-promise') | |
const docsPath = resolve('docs') | |
const docsGit = resolve('docs/.git') | |
const version = require('./package.json').version | |
const repository = require('./package.json').repository.url | |
const executeCommand = (command, args) => { | |
const result = spawnSync(command, args, { cwd: docsPath, encoding: 'utf8' }) | |
if (result.status === 0) { | |
console.log(result.stdout) | |
} else { | |
console.log(result.stderr) | |
exit(result.status) | |
} | |
} | |
fs.removeSync(docsPath) | |
fs.mkdir(docsPath) | |
executeCommand('git', ['init']) | |
executeCommand('git', ['remote', 'add', 'origin', repository + '.git']) | |
executeCommand('git', ['checkout', '-b', 'gh-pages']) | |
executeCommand('git', ['fetch', 'origin', 'gh-pages']) | |
execSync('npm run docs', {encoding: 'utf8'}) | |
executeCommand('git', ['add', '.']) | |
executeCommand('git', ['commit', '-m', 'chore(docs): release docs for v' + version + '']) | |
executeCommand('git', ['push', 'origin', 'gh-pages']) | |
fs.removeSync(docsGit) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment