Skip to content

Commit ee63307

Browse files
committed
fix(config): only try to load js/ts files with jiti
1 parent 5295cf4 commit ee63307

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/config.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,18 @@ const getConfig = async (args) => {
7575
let userConfigFileOptions = {};
7676
if (args.config) {
7777
try {
78-
const config = await jiti.import(path.resolve(args.config));
78+
let config = {};
79+
let filepath = '';
80+
if (args.config.endsWith('.js') || args.config.endsWith('.ts')) {
81+
config = await jiti.import(path.resolve(args.config));
82+
filepath = jiti.esmResolve(path.resolve(args.config));
83+
} else {
84+
const explorer = cosmiconfig('migrations');
85+
const explorerResult = await explorer.load(args.config);
86+
config = explorerResult.config;
87+
filepath = explorerResult.filepath;
88+
}
7989
if (config) {
80-
const filepath = jiti.esmResolve(path.resolve(args.config));
81-
8290
userConfigFileOptions = {
8391
directory: path.resolve(path.dirname(filepath || ''), args.directory || 'migrations'),
8492
...(config || {}),

0 commit comments

Comments
 (0)