prepare-website-branch.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. //@ts-check
  6. /** @typedef {import('../build/utils').IFile} IFile */
  7. const path = require('path');
  8. const cp = require('child_process');
  9. const { REPO_ROOT } = require('./utils');
  10. cp.execSync('git init', {
  11. cwd: path.join(REPO_ROOT, '../monaco-editor-website')
  12. });
  13. const remoteUrl = cp.execSync('git remote get-url origin');
  14. const committerUserName = cp.execSync("git log --format='%an' -1");
  15. const committerEmail = cp.execSync("git log --format='%ae' -1");
  16. cp.execSync(`git config user.name ${committerUserName}`, {
  17. cwd: path.join(REPO_ROOT, '../monaco-editor-website')
  18. });
  19. cp.execSync(`git config user.email ${committerEmail}`, {
  20. cwd: path.join(REPO_ROOT, '../monaco-editor-website')
  21. });
  22. cp.execSync(`git remote add origin ${remoteUrl}`, {
  23. cwd: path.join(REPO_ROOT, '../monaco-editor-website')
  24. });
  25. cp.execSync('git checkout -b gh-pages', {
  26. cwd: path.join(REPO_ROOT, '../monaco-editor-website')
  27. });
  28. cp.execSync('git add .', {
  29. cwd: path.join(REPO_ROOT, '../monaco-editor-website')
  30. });
  31. cp.execSync('git commit -m "Publish website"', {
  32. cwd: path.join(REPO_ROOT, '../monaco-editor-website')
  33. });
  34. console.log('RUN monaco-editor-website>git push origin gh-pages --force');