Commit 256dd142 authored by mohoff's avatar mohoff Committed by Richard Crosby

chore: readSchemaFile now returns null instead of undefined when no schema file is present

parent b3e46994
......@@ -136,7 +136,7 @@ describe('load()', () => {
})
it('skips validating config if schema was not found', () => {
mockedReadSchemaFile.mockReturnValueOnce(undefined)
mockedReadSchemaFile.mockReturnValueOnce(null)
load(mockedParameters)
......@@ -144,7 +144,7 @@ describe('load()', () => {
})
it('skips generating types if schema was not found', () => {
mockedReadSchemaFile.mockReturnValueOnce(undefined)
mockedReadSchemaFile.mockReturnValueOnce(null)
load(mockedParameters)
......
......@@ -30,7 +30,7 @@ export const load = (parameters: Parameters): HydratedConfig => {
const schemaFile = readSchemaFile(normalizedSchemaPath)
if (schemaFile !== undefined) {
if (schemaFile !== null) {
validateJson(config, schemaFile.contents)
generateTypeFromSchema(parameters)
......
......@@ -71,10 +71,10 @@ describe('readSchemaFile()', () => {
jest.clearAllMocks()
})
it('returns undefined when input is not a JSON file', () => {
it('returns null when input is not a JSON file', () => {
mockedIsJson.mockReturnValueOnce(false)
expect(readSchemaFile('not-a-json-file.yaml')).toBeUndefined()
expect(readSchemaFile('not-a-json-file.yaml')).toBeNull()
})
it('reads file by calling getFileFromPath', () => {
......
......@@ -38,9 +38,9 @@ export const readConfigFile = (basePath: string, fileName: string): File => {
export const readConfigFileAtPath = (filePath: string): File =>
readConfigFile(path.dirname(filePath), path.basename(filePath))
export const readSchemaFile = (schemaPath: string): File | undefined => {
export const readSchemaFile = (schemaPath: string): File | null => {
if (R.isNil(schemaPath) || !isJson(schemaPath)) {
return undefined
return null
}
return getFileFromPath(schemaPath)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment