t-comm
Version:
专业、稳定、纯粹的工具库
32 lines (29 loc) • 1.1 kB
JavaScript
import fs__default from 'fs';
import path__default from 'path';
import { execCommand } from '../node/node-command.mjs';
import '@babel/runtime/helpers/typeof';
function checkGitClean(dir) {
if (!fs__default.existsSync(dir)) {
console.error("Not Exist ".concat(dir));
return;
}
var list = fs__default.readdirSync(dir);
// eslint-disable-next-line @typescript-eslint/no-require-imports
var chalk = require('chalk');
list.forEach(function (file) {
var subDir = path__default.resolve(dir, file);
var dotGit = path__default.resolve(subDir, '.git');
var isGitRepo = fs__default.existsSync(dotGit);
if (!isGitRepo) ; else {
var res = execCommand('git status | grep -c "nothing to commit, working tree clean" || true', subDir, 'pipe');
if (res != '1') {
console.log(chalk.red('[not clean] '), subDir);
}
var isNotPush = execCommand('git status | grep -c "Your branch is ahead of" || true', subDir, 'pipe');
if (isNotPush == '1') {
console.log(chalk.blue('[not push]'), subDir);
}
}
});
}
export { checkGitClean };