Skip to content

Commit

Permalink
fix(parse): also extend file based object configurations
Browse files Browse the repository at this point in the history
release-npm
  • Loading branch information
tobua committed Apr 27, 2024
1 parent 70b509e commit cd9bfb6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"format": "bun biome format . --write",
"postinstall": "bun index.ts",
"lint": "bun biome lint .",
"types": "tsc --noEmit"
"types": "tsc"
},
"dependencies": {
"avait": "^1.0.0",
Expand Down
5 changes: 0 additions & 5 deletions parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { existsSync } from 'node:fs'
import { join } from 'node:path'
import { it } from 'avait'
import { merge } from 'ts-deepmerge'
import { state } from './state'
import type { Configuration, Options } from './types'

const isExtension = async (value: string) => {
Expand Down Expand Up @@ -57,10 +56,6 @@ export async function parse(value: Options, configuration: Configuration['config
return configuration.createFile()
}

if (typeof value === 'object' && state.language !== 'json') {
return configuration.createFile(value)
}

// biome-ignore lint/style/noParameterAssign: Easier in this case.
value = extendTemplate(value, configuration)

Expand Down
6 changes: 5 additions & 1 deletion test/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test('Adds configuration files for basic package setup.', () => {
expect(existsSync(join(fixturePath, 'LICENSE.md'))).toBe(true)
})

test('Adds configuration files for basic file setup.', () => {
test('Adds configuration files for basic file setup.', async () => {
const fixturePath = './test/fixture/file'

execSync('bun ./../../../index.ts', {
Expand All @@ -26,6 +26,10 @@ test('Adds configuration files for basic file setup.', () => {
})

expect(existsSync(join(fixturePath, 'prettier.config.js'))).toBe(true)
expect(existsSync(join(fixturePath, 'playwright.config.ts'))).toBe(true)
expect(existsSync(join(fixturePath, 'biome.json'))).toBe(true)

expect(await Bun.file(join(fixturePath, 'biome.json')).text()).not.toContain('recommended')
})

test('Also parses JavaScript configuration.', async () => {
Expand Down
10 changes: 10 additions & 0 deletions test/fixture/file/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,13 @@ export const playwright = {
reuseExistingServer: !process.env.CI,
},
}

export const biome = {
extends: 'recommended',
linter: {
ignore: ['public'],
},
formatter: {
ignore: ['public'],
},
}

0 comments on commit cd9bfb6

Please sign in to comment.