| 1 | const glob = require("glob"); |
| 2 | const { execSync } = require('child_process'); |
| 3 | |
| 4 | console.log('building list of files'); |
| 5 | |
| 6 | const opts = { absolute: true }; |
| 7 | var files = glob.sync("**/*.ts", opts).concat(glob.sync("**/*.tsx", opts)).filter(f => f.indexOf('node_modules') < 0); |
| 8 | |
| 9 | console.log(`found ${files.length} files`); |
| 10 | |
| 11 | files.forEach(f => { |
| 12 | const newName = f.replace(/\.ts(x)?$/, '.js$1'); |
| 13 | console.log(`renaming ${f} to ${newName}`); |
| 14 | execSync(`git mv ${f} ${f.replace(/\.ts(x)?$/, '.js$1')}`); |
| 15 | }); |
| 16 |
curiouser / git-rename-ts-files.js
Last active 3 days ago
Node script for renaming files with .ts or .tsx file extensions to .js or .jsx
Revision 84444c6db63a34e4ff4de5bd1c7110ef7488db8c