Last active
September 9, 2019 09:30
-
-
Save Dante-101/517205eef3d8de0817c59d8ea16e4189 to your computer and use it in GitHub Desktop.
Javascript (JS) to Typescript (TS) File Extension Converter Script
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 fs = require("fs-extra") | |
| const path = require("path") | |
| const globPaths = [ | |
| "src/**/*.js", | |
| "test/**/*.js" | |
| ] | |
| globPaths.forEach(globPath => { | |
| glob(globPath, function (er, files) { | |
| files.forEach(file => { | |
| const dir = path.dirname(file) | |
| const filename = path.basename(file, ".js") | |
| fs.renameSync(path.resolve(file), path.resolve(dir, filename + ".ts")) | |
| }) | |
| }) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment