Created
April 24, 2024 16:31
-
-
Save li-jia-nan/148c245035b62b556f36661c83f951d0 to your computer and use it in GitHub Desktop.
pr.js
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 { spawnSync } = require('node:child_process'); | |
const consoleStd = (std) => { | |
const output = std.stdout.toString(); | |
const error = std.stderr.toString(); | |
if (output) { | |
console.log(output); | |
} | |
if (error) { | |
console.log(error); | |
} | |
}; | |
const repo = process.argv[process.argv.length - 1]; | |
const [repoName, branchName] = repo.split(':'); | |
const target = `https://github.com/${repoName}/ant-design.git`; | |
console.log('Source:', target); | |
// Remove remote first | |
console.log('Clean TMP remote...'); | |
const remoteRemove = spawnSync('git', ['remote', 'remove', 'tmp']); | |
consoleStd(remoteRemove); | |
// Add Remote | |
console.log('Add TMP remote...'); | |
const remoteAdd = spawnSync('git', ['remote', 'add', 'tmp', target]); | |
consoleStd(remoteAdd); | |
// Fetch git fetch tmp featur/expand-action | |
const fetchBR = spawnSync('git', ['fetch', 'tmp', branchName]); | |
consoleStd(fetchBR); | |
// Checkout | |
const checkout = spawnSync('git', ['checkout', '-b', branchName, `tmp/${branchName}`]); | |
consoleStd(checkout); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment