Advertisement
Guest User

Untitled

a guest
Jan 11th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. const execSync = require('child_process').execSync
  2. const spawnSync = require('child_process').spawnSync
  3. const exit = require('process').exit
  4. const resolve = require('path').resolve
  5. const fs = require('fs-promise')
  6.  
  7. const docsPath = resolve('docs')
  8. const docsGit = resolve('docs/.git')
  9.  
  10. const version = require('./package.json').version
  11. const repository = require('./package.json').repository.url
  12.  
  13. const executeCommand = (command, args) => {
  14. const result = spawnSync(command, args, { cwd: docsPath, encoding: 'utf8' })
  15.  
  16. if (result.status === 0) {
  17. console.log(result.stdout)
  18. } else {
  19. console.log(result.stderr)
  20. exit(result.status)
  21. }
  22. }
  23.  
  24. fs.removeSync(docsPath)
  25. fs.mkdir(docsPath)
  26. executeCommand('git', ['init'])
  27. executeCommand('git', ['remote', 'add', 'origin', repository + '.git'])
  28. executeCommand('git', ['fetch', 'origin', 'gh-pages'])
  29. executeCommand('git', ['checkout', 'gh-pages'])
  30. execSync('npm run docs', {encoding: 'utf8'})
  31. executeCommand('git', ['add', '.'])
  32. executeCommand('git', ['commit', '-a', '-m', 'chore(docs): release docs for v' + version + ''])
  33. executeCommand('git', ['push', 'origin', 'gh-pages'])
  34. fs.removeSync(docsGit)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement