Skip to content

Commit

Permalink
plugin updates changed some prettier formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
download13 committed Nov 12, 2022
1 parent b73344a commit 497d7a8
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1176,9 +1176,8 @@ export function processProject(
return structures
}

let moduleSpecifier = outFile.getRelativePathAsModuleSpecifierTo(
importFile
)
let moduleSpecifier =
outFile.getRelativePathAsModuleSpecifierTo(importFile)

if (importFile.isInNodeModules()) {
// Packages within node_modules should not be referenced via relative path
Expand Down Expand Up @@ -1227,24 +1226,22 @@ export function processProject(
.replace(/\.(ts|tsx|d\.ts)$/, '')
const importStatement = `import * as ${options.importGuards} from "${relativeOutPath}";`
const exportStatement = `export { ${options.importGuards} };`
const {
hasImport,
hasExport,
statements,
} = sourceFile.getStatements().reduce(
(reduced, node) => {
const nodeText = node.getText().replace(/\s{2,}/g, ' ')
reduced.hasImport ||= nodeText.includes(
`import * as ${options.importGuards}`
)
reduced.hasExport ||= nodeText.includes(
`export { ${options.importGuards} }`
)
reduced.statements += 1
return reduced
},
{ hasImport: false, hasExport: false, statements: 0 }
)
const { hasImport, hasExport, statements } = sourceFile
.getStatements()
.reduce(
(reduced, node) => {
const nodeText = node.getText().replace(/\s{2,}/g, ' ')
reduced.hasImport ||= nodeText.includes(
`import * as ${options.importGuards}`
)
reduced.hasExport ||= nodeText.includes(
`export { ${options.importGuards} }`
)
reduced.statements += 1
return reduced
},
{ hasImport: false, hasExport: false, statements: 0 }
)
if (!hasImport) {
sourceFile.insertStatements(0, importStatement)
}
Expand Down

0 comments on commit 497d7a8

Please sign in to comment.