-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Store whether code uses require/import/importEquals in importType (#604)
- Loading branch information
Showing
12 changed files
with
92 additions
and
51 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"aws-sdk-js-codemod": patch | ||
--- | ||
|
||
Store whether code uses require/import/importEquals in importType |
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
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
10 changes: 7 additions & 3 deletions
10
src/transforms/v2-to-v3/client-names/getClientNamesRecord.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
import { Collection, JSCodeshift } from "jscodeshift"; | ||
|
||
import { hasRequire } from "../modules"; | ||
import { ImportType } from "../modules"; | ||
import { getClientNamesFromDeepImport } from "./getClientNamesFromDeepImport"; | ||
import { getClientNamesRecordFromImport } from "./getClientNamesRecordFromImport"; | ||
import { getClientNamesRecordFromRequire } from "./getClientNamesRecordFromRequire"; | ||
|
||
export const getClientNamesRecord = (j: JSCodeshift, source: Collection<unknown>) => { | ||
export const getClientNamesRecord = ( | ||
j: JSCodeshift, | ||
source: Collection<unknown>, | ||
importType: ImportType | ||
) => { | ||
const clientNamesFromDeepImport = getClientNamesFromDeepImport(source.toSource()); | ||
return hasRequire(j, source) | ||
return importType === ImportType.REQUIRE | ||
? getClientNamesRecordFromRequire(j, source, clientNamesFromDeepImport) | ||
: getClientNamesRecordFromImport(j, source, clientNamesFromDeepImport); | ||
}; |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Collection, JSCodeshift } from "jscodeshift"; | ||
import { hasImportEquals } from "./hasImportEquals"; | ||
import { hasRequire } from "./hasRequire"; | ||
import { ImportType } from "./types"; | ||
|
||
export const getImportType = (j: JSCodeshift, source: Collection<unknown>) => | ||
hasRequire(j, source) | ||
? ImportType.REQUIRE | ||
: hasImportEquals(j, source) | ||
? ImportType.IMPORT_EQUALS | ||
: ImportType.IMPORT; |
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
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
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
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
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