Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support .tsx and .jsx files from CLI #448

Merged
merged 6 commits into from
Aug 26, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async function buildDirectory(
outDirPath: string,
options: CLIOptions,
): Promise<void> {
const extension = options.sucraseOptions.transforms.includes("typescript") ? ".ts" : ".js";
const extension = options.sucraseOptions.transforms.includes("typescript") ? /.tsx?$/ : /.jsx?$/;
if (!(await exists(outDirPath))) {
await mkdir(outDirPath);
}
Expand All @@ -87,10 +87,8 @@ async function buildDirectory(
const outChildPath = join(outDirPath, child);
if ((await stat(srcChildPath)).isDirectory()) {
await buildDirectory(srcChildPath, outChildPath, options);
} else if (srcChildPath.endsWith(extension)) {
const outPath = `${outChildPath.substr(0, outChildPath.length - extension.length)}.${
options.outExtension
}`;
} else if (extension.test(srcChildPath)) {
const outPath = _path.basename(outChildPath, _path.extname(outChildPath)) + '.' + options.outExtension;
ricardobeat marked this conversation as resolved.
Show resolved Hide resolved
await buildFile(srcChildPath, outPath, options);
}
}
Expand Down