fix: Fallback for pre Strapi 4.2

pull/59/head
Boaz Poolman 2022-06-14 18:38:05 +02:00
parent c9e45c3909
commit 56ee854e71
1 changed files with 22 additions and 15 deletions

View File

@ -7,7 +7,6 @@ const chalk = require('chalk');
const inquirer = require('inquirer'); const inquirer = require('inquirer');
const { isEmpty } = require('lodash'); const { isEmpty } = require('lodash');
const strapi = require('@strapi/strapi'); // eslint-disable-line const strapi = require('@strapi/strapi'); // eslint-disable-line
const tsUtils = require('@strapi/typescript-utils'); // eslint-disable-line
const gitDiff = require('git-diff'); const gitDiff = require('git-diff');
const warnings = require('./warnings'); const warnings = require('./warnings');
@ -16,6 +15,9 @@ const packageJSON = require('../package.json');
const program = new Command(); const program = new Command();
const getStrapiApp = async () => { const getStrapiApp = async () => {
try {
const tsUtils = require('@strapi/typescript-utils'); // eslint-disable-line
const appDir = process.cwd(); const appDir = process.cwd();
const isTSProject = await tsUtils.isUsingTypeScript(appDir); const isTSProject = await tsUtils.isUsingTypeScript(appDir);
const outDir = await tsUtils.resolveOutDir(appDir); const outDir = await tsUtils.resolveOutDir(appDir);
@ -32,6 +34,11 @@ const getStrapiApp = async () => {
const app = await strapi({ appDir, distDir }).load(); const app = await strapi({ appDir, distDir }).load();
return app; return app;
} catch (e) {
// Fallback for pre Strapi 4.2.
const app = await strapi().load();
return app;
}
}; };
const initTable = (head) => { const initTable = (head) => {