We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent eeebefe commit d82070dCopy full SHA for d82070d
src/cli.ts
@@ -42,11 +42,13 @@ program
42
for (const file of files) {
43
const filePath = path.resolve(file);
44
const newPath = filePath.replace(/\.jsx?$/, '.tsx');
45
-
+ const temporaryPath = filePath.replace(/\.jsx?$/, `_js2ts_${+new Date()}.tsx`);
46
try {
47
- fs.renameSync(filePath, newPath);
48
- const result = run(newPath, prettierOptions);
+ fs.copyFileSync(filePath, temporaryPath);
+ const result = run(temporaryPath, prettierOptions);
49
fs.writeFileSync(newPath, result);
50
+ fs.unlinkSync(filePath);
51
+ fs.unlinkSync(temporaryPath);
52
} catch (error) {
53
console.warn(`Failed to convert ${file}`);
54
console.warn(error);
0 commit comments