41 lines
893 B
JavaScript
41 lines
893 B
JavaScript
#!/usr/bin/env node
|
|
|
|
const { version } = require('../package.json');
|
|
|
|
function printHelp() {
|
|
console.log(`zy-gbs-cmd <command>
|
|
|
|
使用:
|
|
zy-gbs-cmd help 查看帮助
|
|
zy-gbs-cmd v 查看版本
|
|
zy-gbs-cmd push java [environment] 构建并推送到 Java Git 仓库
|
|
`);
|
|
}
|
|
|
|
async function main() {
|
|
const [, , command, argument, environment] = process.argv;
|
|
|
|
if (!command || command === 'help') {
|
|
printHelp();
|
|
return;
|
|
}
|
|
|
|
if (command === 'v') {
|
|
console.log(`当前版本: v${version}`);
|
|
return;
|
|
}
|
|
|
|
if (command === 'push' && argument === 'java') {
|
|
await require('../src/push')({ environment });
|
|
return;
|
|
}
|
|
|
|
console.error('无效命令,请执行 zy-gbs-cmd help 查看用法。');
|
|
process.exitCode = 1;
|
|
}
|
|
|
|
main().catch(error => {
|
|
console.error(`推送失败: ${error.message}`);
|
|
process.exitCode = 1;
|
|
});
|