Handle yarn install in generated project

This commit is contained in:
Jim LAURIE 2018-07-02 17:00:44 +02:00
parent ed89c8404d
commit d383a75154

View File

@ -16,6 +16,15 @@ const _ = require('lodash');
const pluginsDirPath = path.join(process.cwd(), 'plugins');
const adminDirPath = path.join(process.cwd(), 'admin');
let packageManager;
try {
packageManager = require(path.resolve(process.cwd(), 'package')).strapi.packageManager;
} catch (error) {
packageManager = 'npm';
}
const installCmd = packageManager === 'yarn' ? 'yarn install --production --ignore-scripts' : 'npm install --prod --ignore-scripts';
/* eslint-disable no-console */
// Install admin dependencies
@ -26,7 +35,7 @@ try {
// Check if path is existing.
fs.accessSync(adminDirPath, fs.constants.R_OK | fs.constants.W_OK);
const install = exec(`cd "${adminDirPath}" && npm install --prod --ignore-scripts`, {
const install = exec(`cd "${adminDirPath}" && ${installCmd}`, {
silent: true
});
@ -62,7 +71,7 @@ try {
console.log('📦 Installing packages...');
try {
const install = exec(`cd "${pluginPath}" && npm install --prod --ignore-scripts`, {
const install = exec(`cd "${pluginPath}" && ${installCmd}`, {
silent: true
});