File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change 1- /* eslint-disable @typescript-eslint/no-explicit-any */
1+ import fs from 'fs/promises'
22import { findUp } from 'find-up-simple'
33import type {
44 ReleaserStepsOptions ,
@@ -143,6 +143,20 @@ async function loadAndSetIfQuery(
143143 }
144144}
145145
146+ async function importConfig ( path : string ) {
147+ if ( path . endsWith ( '.json' ) ) {
148+ const json = await fs . readFile ( path , 'utf-8' )
149+ const config = JSON . parse ( json ) as SimpleReleaseConfig
150+
151+ return config
152+ }
153+
154+ const module = await import ( path ) as SimpleReleaseConfig | { default : SimpleReleaseConfig }
155+ const config = 'default' in module ? module . default : module
156+
157+ return config
158+ }
159+
146160/**
147161 * Load simple-release config.
148162 * @param requirements
@@ -172,8 +186,7 @@ export async function load(
172186
173187 if ( foundPath ) {
174188 try {
175- const module = await import ( foundPath ) as SimpleReleaseConfig | { default : SimpleReleaseConfig }
176- const config = 'default' in module ? module . default : module
189+ const config = await importConfig ( foundPath )
177190
178191 validate ( config , reqs )
179192
You can’t perform that action at this time.
0 commit comments