mirror of
https://github.com/strapi/strapi.git
synced 2025-11-11 15:49:50 +00:00
Fix develop command
Signed-off-by: soupette <cyril@strapi.io>
This commit is contained in:
parent
3cbc9c24df
commit
d47d741664
@ -18,21 +18,25 @@ const { buildTypeScript, buildAdmin } = require('./builders');
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
module.exports = async function({ build, watchAdmin, polling, browser }) {
|
module.exports = async function({ build, watchAdmin, polling, browser }) {
|
||||||
let dir = process.cwd();
|
const currentDirectory = process.cwd();
|
||||||
|
|
||||||
const isTSProject = await tsUtils.isTypeScriptProject(dir);
|
const isTSProject = await tsUtils.isTypeScriptProject(currentDirectory);
|
||||||
|
const buildDestDir = isTSProject ? path.join(currentDirectory, 'dist') : currentDirectory;
|
||||||
if (isTSProject) {
|
|
||||||
dir = path.join(dir, 'dist');
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (cluster.isMaster || cluster.isPrimary) {
|
if (cluster.isMaster || cluster.isPrimary) {
|
||||||
return primaryProcess({ dir, build, browser, watchAdmin });
|
return primaryProcess({
|
||||||
|
buildDestDir,
|
||||||
|
currentDirectory,
|
||||||
|
dir: buildDestDir,
|
||||||
|
build,
|
||||||
|
browser,
|
||||||
|
watchAdmin,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cluster.isWorker) {
|
if (cluster.isWorker) {
|
||||||
return workerProcess({ dir, watchAdmin, polling });
|
return workerProcess({ dir: buildDestDir, watchAdmin, polling });
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
@ -40,23 +44,28 @@ module.exports = async function({ build, watchAdmin, polling, browser }) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const primaryProcess = async ({ dir, build, watchAdmin, browser }) => {
|
const primaryProcess = async ({ buildDestDir, currentDirectory, build, watchAdmin, browser }) => {
|
||||||
const currentDirectory = process.cwd();
|
|
||||||
const isTSProject = await tsUtils.isTypeScriptProject(currentDirectory);
|
const isTSProject = await tsUtils.isTypeScriptProject(currentDirectory);
|
||||||
|
|
||||||
if (isTSProject) {
|
if (isTSProject) {
|
||||||
await buildTypeScript({ srcDir: currentDirectory, watch: true });
|
await buildTypeScript({ srcDir: currentDirectory, watch: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
const config = loadConfiguration(dir);
|
const config = loadConfiguration(buildDestDir);
|
||||||
const serveAdminPanel = getOr(true, 'admin.serveAdminPanel')(config);
|
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
|
// Don't run the build process if the admin is in watch mode
|
||||||
if (build && !watchAdmin && serveAdminPanel && !buildExists) {
|
if (build && !watchAdmin && serveAdminPanel && !buildExists) {
|
||||||
try {
|
try {
|
||||||
await buildAdmin({ dir, optimization: false, forceBuild: false });
|
await buildAdmin({
|
||||||
|
buildDestDir,
|
||||||
|
forceBuild: false,
|
||||||
|
isTSProject,
|
||||||
|
optimization: false,
|
||||||
|
srcDir: currentDirectory,
|
||||||
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user