Skip to content

Commit 251d8df

Browse files
committed
feat: avoid compilation is project already compiled
1 parent 8a7d4ba commit 251d8df

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

server/cli.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import inquirer from 'inquirer';
88
import isEmpty from 'lodash/isEmpty';
99
import { createStrapi, compileStrapi } from '@strapi/strapi';
1010
import gitDiff from 'git-diff';
11+
import tsUtils from '@strapi/typescript-utils';
1112

1213
import warnings from './warnings';
1314
import packageJSON from '../package.json';
@@ -17,7 +18,17 @@ const program = new Command();
1718
const getStrapiApp = async () => {
1819
process.env.CONFIG_SYNC_CLI = 'true';
1920

20-
const appContext = await compileStrapi();
21+
const appDir = process.cwd();
22+
const isTSProject = await tsUtils.isUsingTypeScript(appDir);
23+
const outDir = await tsUtils.resolveOutDir(appDir);
24+
const alreadyCompiled = await fs.existsSync(outDir);
25+
26+
let appContext;
27+
if (!isTSProject || !alreadyCompiled) {
28+
appContext = await compileStrapi();
29+
} else {
30+
appContext = { appDir, outDir };
31+
}
2132
const app = await createStrapi(appContext).load();
2233
return app;
2334
};

0 commit comments

Comments
 (0)