@@ -7,7 +7,6 @@ const chalk = require('chalk');
77const inquirer = require ( 'inquirer' ) ;
88const { isEmpty } = require ( 'lodash' ) ;
99const strapi = require ( '@strapi/strapi' ) ; // eslint-disable-line
10- const tsUtils = require ( '@strapi/typescript-utils' ) ; // eslint-disable-line
1110const gitDiff = require ( 'git-diff' ) ;
1211
1312const warnings = require ( './warnings' ) ;
@@ -16,22 +15,30 @@ const packageJSON = require('../package.json');
1615const program = new Command ( ) ;
1716
1817const getStrapiApp = async ( ) => {
19- const appDir = process . cwd ( ) ;
20- const isTSProject = await tsUtils . isUsingTypeScript ( appDir ) ;
21- const outDir = await tsUtils . resolveOutDir ( appDir ) ;
22-
23- if ( isTSProject ) {
24- await tsUtils . compile ( appDir , {
25- watch : false ,
26- configOptions : { options : { incremental : true } } ,
27- } ) ;
28- }
18+ try {
19+ const tsUtils = require ( '@strapi/typescript-utils' ) ; // eslint-disable-line
20+
21+ const appDir = process . cwd ( ) ;
22+ const isTSProject = await tsUtils . isUsingTypeScript ( appDir ) ;
23+ const outDir = await tsUtils . resolveOutDir ( appDir ) ;
24+
25+ if ( isTSProject ) {
26+ await tsUtils . compile ( appDir , {
27+ watch : false ,
28+ configOptions : { options : { incremental : true } } ,
29+ } ) ;
30+ }
2931
30- const distDir = isTSProject ? outDir : appDir ;
32+ const distDir = isTSProject ? outDir : appDir ;
3133
32- const app = await strapi ( { appDir, distDir } ) . load ( ) ;
34+ const app = await strapi ( { appDir, distDir } ) . load ( ) ;
3335
34- return app ;
36+ return app ;
37+ } catch ( e ) {
38+ // Fallback for pre Strapi 4.2.
39+ const app = await strapi ( ) . load ( ) ;
40+ return app ;
41+ }
3542} ;
3643
3744const initTable = ( head ) => {
0 commit comments