Created
January 27, 2022 20:59
-
-
Save julioxavierr/008a0cc3cd6e0123f7afba46f14451b5 to your computer and use it in GitHub Desktop.
Migrate JS file to TS
This file contains 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
var join = require('path').join; | |
var cp = require('child_process'); | |
/** | |
* Migrate a file to TypeScript. | |
* | |
* @example | |
* // will rename file and try to infer types | |
* yarn ts:migrate ./src/utils.js | |
* | |
*/ | |
(() => { | |
const args = process.argv.filter((arg) => !arg.includes('node') && !arg.includes('scripts')); | |
args.forEach((path) => { | |
const tsPath = path.replace('js', 'ts'); | |
cp.exec(`yarn ts-migrate rename . -s "${path}" && yarn ts-migrate migrate . -s "${tsPath}"`).stdout.pipe( | |
process.stdout | |
); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment