Created
March 6, 2018 17:35
-
-
Save curiousercreative/76edc6b95a47f46c71e497df689b68ee to your computer and use it in GitHub Desktop.
Node script for renaming files with .ts or .tsx file extensions to .js or .jsx
This file contains hidden or 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
const glob = require("glob"); | |
const { execSync } = require('child_process'); | |
console.log('building list of files'); | |
const opts = { absolute: true }; | |
var files = glob.sync("**/*.ts", opts).concat(glob.sync("**/*.tsx", opts)).filter(f => f.indexOf('node_modules') < 0); | |
console.log(`found ${files.length} files`); | |
files.forEach(f => { | |
const newName = f.replace(/\.ts(x)?$/, '.js$1'); | |
console.log(`renaming ${f} to ${newName}`); | |
execSync(`git mv ${f} ${f.replace(/\.ts(x)?$/, '.js$1')}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment