Created
September 5, 2017 22:08
-
-
Save psealock/ffa6fc914af5213e769463bf20de1227 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @format */ | |
var fs = require( 'fs' ); | |
function replaceLine( file ) { | |
fs.readFile( file, 'utf8', function( err, data ) { | |
if ( err ) { | |
return console.log( err ); | |
} | |
var result = data.replace( | |
/import PropTypes from 'prop-types';\n\n(?=import)/g, | |
"import PropTypes from 'prop-types';\n" | |
); | |
fs.writeFile( file, result, 'utf8', function( err ) { | |
if ( err ) return console.log( err ); | |
} ); | |
} ); | |
} | |
replaceLine( process.argv[ 2 ] ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Initialize from the provided arguments | |
TARGET="${1:?No target supplied. Please provide a target directory or file.}" | |
FILES=$(find $TARGET -type f -name '*.jsx' -o -name '*.js') | |
for filename in $FILES; do | |
echo "Processing $filename" | |
node proptypes-extra-line.js $filename | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment