UNPKG

jest-codemods

Version:

Codemods for migrating test files to Jest

34 lines (33 loc) 1.28 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = checkGitStatus; var chalk_1 = __importDefault(require("chalk")); var is_git_clean_1 = __importDefault(require("is-git-clean")); function checkGitStatus(force) { if (force === void 0) { force = false; } var clean = false; var errorMessage = 'Unable to determine if git directory is clean'; try { clean = is_git_clean_1.default.sync(process.cwd()); errorMessage = 'Git directory is not clean'; } catch (err) { if (err && err.stderr && err.stderr.indexOf('Not a git repository') >= 0) { clean = true; } } if (!clean) { if (force) { console.log("WARNING: ".concat(errorMessage, ". Forcibly continuing.\n")); } else { console.log('Thank you for using jest-codemods!'); console.log(chalk_1.default.yellow('\nBut before we continue, please stash or commit your git changes.')); console.log('\nYou may use the --force flag to override this safety check.'); process.exit(1); } } }