Skip to content

Commit

Permalink
refactor: use default literal instead default variable
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-melanson committed Sep 30, 2023
1 parent 1bccbfa commit 6b9478e
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/cli/config/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,15 @@ export const run: CliCommand = async (args: CliCommandArgs /* , logger: Logger *
body = JSON.stringify({ ...pkgJson, jest: jestConfig }, undefined, ' ')
} else {
// js config
const usesModules = pkgJson.type === 'module'

const content = []
if (!jestPreset) {
content.push(`${preset.jsImport('tsjPreset')};`, '')
}
content.push(`/** @type {import('ts-jest').JestConfigWithTsJest} */`)
content.push(usesModules ? 'const jestConfig = {' : 'module.exports = {')

const usesModules = pkgJson.type === 'module'
content.push(usesModules ? 'export default {' : 'module.exports = {')

if (jestPreset) {
content.push(` preset: '${preset.name}',`)
} else {
Expand All @@ -133,10 +134,6 @@ export const run: CliCommand = async (args: CliCommandArgs /* , logger: Logger *
}
content.push('};')

if (usesModules) {
content.push('\nexport default jestConfig;')
}

// join all together
body = content.join('\n')
}
Expand Down

0 comments on commit 6b9478e

Please # to comment.