mirror of
https://github.com/pnpm/pnpm.git
synced 2026-02-10 15:12:46 -05:00
* fix: `shamefullyHoist` set via `updateConfig` in `.pnpmfile.cjs` * refactor: consolidate derived config processing to cli-utils Move shamefullyHoist → publicHoistPattern conversion from config/config to cli-utils/getConfig.ts as suggested in review. * test(config): update tests for derived config processing move * refactor: move applyDerivedConfig to cli-utils * refactor: move applyDerivedConfig to cli-utils * test: use unit test for hoist: false in cli-utils * revert: not needed changes close #10271
45 lines
1.0 KiB
TypeScript
45 lines
1.0 KiB
TypeScript
/// <reference path="../../../__typings__/index.d.ts"/>
|
|
import fs from 'fs'
|
|
import { getConfig } from '@pnpm/cli-utils'
|
|
import { prepare } from '@pnpm/prepare'
|
|
import { jest } from '@jest/globals'
|
|
|
|
beforeEach(() => {
|
|
jest.spyOn(console, 'warn')
|
|
})
|
|
|
|
afterEach(() => {
|
|
jest.mocked(console.warn).mockRestore()
|
|
})
|
|
|
|
test('console a warning when the .npmrc has an env variable that does not exist', async () => {
|
|
prepare()
|
|
|
|
fs.writeFileSync('.npmrc', 'registry=${ENV_VAR_123}', 'utf8')
|
|
|
|
await getConfig({
|
|
json: false,
|
|
}, {
|
|
workspaceDir: '.',
|
|
excludeReporter: false,
|
|
rcOptionsTypes: {},
|
|
})
|
|
|
|
expect(console.warn).toHaveBeenCalledWith(expect.stringContaining('Failed to replace env in config: ${ENV_VAR_123}'))
|
|
})
|
|
|
|
test('hoist: false removes hoistPattern', async () => {
|
|
prepare()
|
|
|
|
const config = await getConfig({
|
|
hoist: false,
|
|
}, {
|
|
workspaceDir: '.',
|
|
excludeReporter: false,
|
|
rcOptionsTypes: {},
|
|
})
|
|
|
|
expect(config.hoist).toBe(false)
|
|
expect(config.hoistPattern).toBeUndefined()
|
|
})
|