From d47d741664cff2321bb52fd75a73fc651bad691f Mon Sep 17 00:00:00 2001 From: soupette Date: Wed, 9 Mar 2022 17:49:27 +0100 Subject: [PATCH] Fix develop command Signed-off-by: soupette --- .../src/admin/{app.tsx => app.example.tsx} | 0 packages/core/strapi/lib/commands/develop.js | 35 ++++++++++++------- 2 files changed, 22 insertions(+), 13 deletions(-) rename examples/kitchensink-ts/src/admin/{app.tsx => app.example.tsx} (100%) diff --git a/examples/kitchensink-ts/src/admin/app.tsx b/examples/kitchensink-ts/src/admin/app.example.tsx similarity index 100% rename from examples/kitchensink-ts/src/admin/app.tsx rename to examples/kitchensink-ts/src/admin/app.example.tsx diff --git a/packages/core/strapi/lib/commands/develop.js b/packages/core/strapi/lib/commands/develop.js index 502e885be2..7b91b31ad3 100644 --- a/packages/core/strapi/lib/commands/develop.js +++ b/packages/core/strapi/lib/commands/develop.js @@ -18,21 +18,25 @@ const { buildTypeScript, buildAdmin } = require('./builders'); * */ module.exports = async function({ build, watchAdmin, polling, browser }) { - let dir = process.cwd(); + const currentDirectory = process.cwd(); - const isTSProject = await tsUtils.isTypeScriptProject(dir); - - if (isTSProject) { - dir = path.join(dir, 'dist'); - } + const isTSProject = await tsUtils.isTypeScriptProject(currentDirectory); + const buildDestDir = isTSProject ? path.join(currentDirectory, 'dist') : currentDirectory; try { if (cluster.isMaster || cluster.isPrimary) { - return primaryProcess({ dir, build, browser, watchAdmin }); + return primaryProcess({ + buildDestDir, + currentDirectory, + dir: buildDestDir, + build, + browser, + watchAdmin, + }); } if (cluster.isWorker) { - return workerProcess({ dir, watchAdmin, polling }); + return workerProcess({ dir: buildDestDir, watchAdmin, polling }); } } catch (e) { console.error(e); @@ -40,23 +44,28 @@ module.exports = async function({ build, watchAdmin, polling, browser }) { } }; -const primaryProcess = async ({ dir, build, watchAdmin, browser }) => { - const currentDirectory = process.cwd(); +const primaryProcess = async ({ buildDestDir, currentDirectory, build, watchAdmin, browser }) => { const isTSProject = await tsUtils.isTypeScriptProject(currentDirectory); if (isTSProject) { await buildTypeScript({ srcDir: currentDirectory, watch: true }); } - const config = loadConfiguration(dir); + const config = loadConfiguration(buildDestDir); const serveAdminPanel = getOr(true, 'admin.serveAdminPanel')(config); - const buildExists = fs.existsSync(path.join(dir, 'build')); + const buildExists = fs.existsSync(path.join(buildDestDir, 'build')); // Don't run the build process if the admin is in watch mode if (build && !watchAdmin && serveAdminPanel && !buildExists) { try { - await buildAdmin({ dir, optimization: false, forceBuild: false }); + await buildAdmin({ + buildDestDir, + forceBuild: false, + isTSProject, + optimization: false, + srcDir: currentDirectory, + }); } catch (err) { process.exit(1); }