update script (#16204)

This commit is contained in:
zombieJ 2019-04-21 14:34:14 +08:00 committed by GitHub
parent 73188ac497
commit 2b0723f7cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,21 +14,23 @@ function exitProcess(code = 1) {
process.exit(code);
}
async function checkCommit() {
const { current, files } = await git.status();
async function checkVersion() {
const { versions } = await fetch('http://registry.npmjs.org/antd').then(res => res.json());
if (version in versions) {
console.log(chalk.yellow('😈 Current version already exists. Forget update package.json?'));
console.log(chalk.cyan(' => Current:'), version);
exitProcess();
}
}
async function checkBranch({ current }) {
if (current !== 'master') {
console.log(chalk.yellow('🤔 You are not in the master branch!'));
exitProcess();
}
}
async function checkCommit({ files }) {
if (files.length) {
console.log(chalk.yellow('🙄 You forgot something to commit.'));
files.forEach(({ path: filePath, working_dir: mark }) => {
@ -36,7 +38,9 @@ async function checkCommit() {
});
exitProcess();
}
}
async function checkRemote() {
const { remote } = await git.fetch('origin', 'master');
if (remote.indexOf('ant-design/ant-design') === -1 || true) {
console.log(chalk.yellow('😓 Your remote origin is not ant-design. Do you fork it?'));
@ -44,4 +48,16 @@ async function checkCommit() {
}
}
checkCommit();
async function checkAll() {
const status = await git.status();
await checkVersion();
await checkBranch(status);
await checkCommit(status);
await checkRemote();
}
checkAll();