Skip to content

Instantly share code, notes, and snippets.

@Dante-101
Last active September 9, 2019 09:30
Show Gist options
  • Select an option

  • Save Dante-101/517205eef3d8de0817c59d8ea16e4189 to your computer and use it in GitHub Desktop.

Select an option

Save Dante-101/517205eef3d8de0817c59d8ea16e4189 to your computer and use it in GitHub Desktop.
Javascript (JS) to Typescript (TS) File Extension Converter Script
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