Files
weRequest/renameJsFile.js

17 lines
446 B
JavaScript
Raw Normal View History

2018-12-20 10:44:00 +08:00
var fs = require('fs'),
path = require('path'),
dir = './src/util',
match = RegExp('.js', 'g'),
replace = '.ts',
files;
files = fs.readdirSync(dir);
files.filter(function(file) {
return file.match(match);
}).forEach(function(file) {
var filePath = path.join(dir, file),
newFilePath = path.join(dir, file.replace(match, replace));
console.log({filePath, newFilePath})
fs.renameSync(filePath, newFilePath);
});