From b59ff5dbda4ac70889b47788374debf949f789e7 Mon Sep 17 00:00:00 2001 From: Ezequiel Ramos Date: Mon, 13 May 2024 16:21:47 -0300 Subject: [PATCH] work with ts or js --- bin/index.ts | 11 ++++++++++- package.json | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/bin/index.ts b/bin/index.ts index 79041f0..0432636 100755 --- a/bin/index.ts +++ b/bin/index.ts @@ -150,7 +150,16 @@ async function generateMigration(migrationName) { async function upgrade() { try { const pathName = process.cwd(); - const initFile = await import(pathName + '/gina/initializeModels.ts'); + + const ginaFolder = (await readdir(pathName + '/gina')).filter(file => !file.includes('.d.ts') && !file.includes('.js.map')); + + let initializeModelsFile = 'initializeModels.ts'; + + if (ginaFolder.includes('initializeModels.js')) { + initializeModelsFile = 'initializeModels.js'; + } + + const initFile = await import(pathName + '/gina/' + initializeModelsFile); console.log('loading models...'); let initializeModels = initFile.initializeModels; diff --git a/package.json b/package.json index 3da04db..9e846d9 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "gina-cli": "./bin/index.ts" }, "types": "./dist/gina.d.ts", - "version": "0.0.14", + "version": "0.0.15", "description": "Gina is a tool to auto-generate and run migrations based on Sequelize ORM.", "scripts": { "eslint": "eslint .",