Last active
March 28, 2019 15:59
-
-
Save vilindberg/d299166d60b239dbd1121d2a7059b4b2 to your computer and use it in GitHub Desktop.
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 fs = require('fs') | |
| const path = require('path') | |
| function logFiles(dir, excludes) { | |
| for (const fileName of fs.readdirSync(dir)) { | |
| const filePath = path.resolve(dir, fileName) | |
| const stats = fs.statSync(filePath) | |
| if (excludes.some(exclude => filePath.includes(exclude))) { | |
| continue | |
| } | |
| if (stats.isDirectory()) { | |
| logFiles(filePath, excludes) | |
| } else { | |
| if (filePath.includes('.js')) { | |
| const newFilePath = filePath.replace('.js', '.ts') | |
| fs.rename(filePath, newFilePath, () => { | |
| console.log(`RENAMED ${filePath} to ${newFilePath}`) | |
| }) | |
| } | |
| } | |
| } | |
| } | |
| logFiles(`${__dirname}/random-folder`, ['random-folder-1', 'random-folder-2']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment