Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save okovalov/befb3cfa406be8a397f7ed7dd3fddb65 to your computer and use it in GitHub Desktop.
Save okovalov/befb3cfa406be8a397f7ed7dd3fddb65 to your computer and use it in GitHub Desktop.
React-PropTypes-to-prop-types

For one time execution of react-codemod/React-PropTypes-to-prop-types without installation

Usage: run npx https://gist.github.com/ilio/2aaab43daa4cec681ae8520eb052a873 <path> in the project folder.

Example: npx https://gist.github.com/ilio/2aaab43daa4cec681ae8520eb052a873 src

{
"name": "React-PropTypes-to-prop-types",
"version": "0.0.0",
"bin": "./React-PropTypes-to-prop-types.js",
"dependencies": {
"react-codemod": "https://github.com/reactjs/react-codemod.git"
}
}
#!/usr/bin/env node
console.log('v6', process.argv, process.cwd(), __dirname);
const {exec} = require('child_process');
const path = require('path');
exec('npm bin', {cwd: __dirname}, (err, stdout, stderr) => {
if (err) {
console.error(err);
} else {
console.log('bin', stdout);
const binFolder = /^(.+)[\r\n]*/g.exec(stdout)[1];
const targetFolder = path.join(process.cwd(), process.argv[2]);
const jscodeshift = path.join(binFolder, 'jscodeshift');
console.log('jscodeshift', jscodeshift, 'targetFolder', targetFolder);
exec(jscodeshift + ' -t ./node_modules/react-codemod/transforms/React-PropTypes-to-prop-types.js ' + targetFolder, {cwd: __dirname}, (err, stdout, stderr) => {
if (err) {
console.error(err);
} else {
console.log(stdout);
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment