MCPcopy Index your code
hub / github.com/reactjs/react-codemod / checkGitStatus

Function checkGitStatus

bin/cli.js:14–42  ·  view source on GitHub ↗
(force)

Source from the content-addressed store, hash-verified

12const jscodeshiftExecutable = require.resolve('.bin/jscodeshift');
13
14function checkGitStatus(force) {
15 let clean = false;
16 let errorMessage = 'Unable to determine if git directory is clean';
17 try {
18 clean = isGitClean.sync(process.cwd());
19 errorMessage = 'Git directory is not clean';
20 } catch (err) {
21 if (err && err.stderr && err.stderr.indexOf('Not a git repository') >= 0) {
22 clean = true;
23 }
24 }
25
26 if (!clean) {
27 if (force) {
28 console.log(`WARNING: ${errorMessage}. Forcibly continuing.`);
29 } else {
30 console.log('Thank you for using react-codemods!');
31 console.log(
32 chalk.yellow(
33 '\nBut before we continue, please stash or commit your git changes.'
34 )
35 );
36 console.log(
37 '\nYou may use the --force flag to override this safety check.'
38 );
39 process.exit(1);
40 }
41 }
42}
43
44function runTransform({ files, flags, parser, transformer, answers }) {
45 const transformerPath = path.join(transformerDirectory, `${transformer}.js`);

Callers 2

runFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected