git-rename-ts-files.js
· 500 B · JavaScript
Eredeti
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')}`);
});
| 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 |