Skip to content

Commit

Permalink
Support parser=ts (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr committed Mar 9, 2022
1 parent ea49796 commit 8b09b2d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/nervous-rabbits-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"aws-sdk-js-codemod": patch
---

Support parser=ts
14 changes: 8 additions & 6 deletions src/transforms/v2-to-v3/transformer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ describe("v2-to-v3", () => {
.filter((fileName) => fileName.endsWith(".input.ts"))
.map((fileName) => fileName.replace(".input.ts", ""));

it.each(testFilePrefixes)(`transforms correctly using "%s" data`, (testFilePrefix) => {
const path = join(fixtureDir, testFilePrefix + `.input.ts`);
const source = readFileSync(path, "utf8");
const input = { path, source };
const expectedOutput = readFileSync(join(fixtureDir, testFilePrefix + `.output.ts`), "utf8");
runInlineTest(transformer, null, input, expectedOutput);
describe.each([{}, { parser: "ts" }])("testOptions: %o", (testOptions) => {
it.each(testFilePrefixes)(`transforms correctly using "%s" data`, (testFilePrefix) => {
const path = join(fixtureDir, testFilePrefix + `.input.ts`);
const source = readFileSync(path, "utf8");
const input = { path, source };
const expectedOutput = readFileSync(join(fixtureDir, testFilePrefix + `.output.ts`), "utf8");
runInlineTest(transformer, null, input, expectedOutput, testOptions);
});
});
});
2 changes: 1 addition & 1 deletion src/transforms/v2-to-v3/utils/addV3ClientRequire.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const addV3ClientRequire = (
init: {
type: "CallExpression",
callee: { type: "Identifier", name: "require" },
arguments: [{ type: "Literal", value: v3ClientPackageName }],
arguments: [{ value: v3ClientPackageName }],
},
});

Expand Down
2 changes: 1 addition & 1 deletion src/transforms/v2-to-v3/utils/getImportIdentifierName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ export const getImportIdentifierName = (
): string | undefined =>
source
.find(j.ImportDeclaration, {
source: { type: "Literal", value: literalValue },
source: { value: literalValue },
})
.nodes()[0]?.specifiers[0]?.local.name;
2 changes: 1 addition & 1 deletion src/transforms/v2-to-v3/utils/getRequireIdentifierName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const getRequireIdentifierName = (
init: {
type: "CallExpression",
callee: { type: "Identifier", name: "require" },
arguments: [{ type: "Literal", value: literalValue }],
arguments: [{ value: literalValue }],
},
})
.nodes()[0]?.id as Identifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const getRequireVariableDeclaration = (
init: {
type: "CallExpression",
callee: { type: "Identifier", name: "require" },
arguments: [{ type: "Literal", value: literalValue }],
arguments: [{ value: literalValue }],
},
},
],
Expand Down

0 comments on commit 8b09b2d

Please sign in to comment.