Fix temp directory reference for Yarn

Also: fix logic detecting installation with Yarn and fix minor linter
errors.

related #1548 & #1463
This commit is contained in:
Alberto Maturano 2018-07-11 22:44:04 -05:00
parent 2482d5488f
commit beeaa55bd5
2 changed files with 7 additions and 7 deletions

View File

@ -214,7 +214,7 @@ module.exports = (scope, cb) => {
let packageCmd = packageManager.commands('install --prefix', scope.tmpPath); let packageCmd = packageManager.commands('install --prefix', scope.tmpPath);
// Manually create the temp directory for yarn // Manually create the temp directory for yarn
if (!isStrapiInstalledWithNPM) { if (!isStrapiInstalledWithNPM) {
shell.exec('mkdir tmp'); shell.exec(`mkdir ${scope.tmpPath}`);
} }
let cmd = `${packageCmd} ${scope.client.connector}@alpha`; let cmd = `${packageCmd} ${scope.client.connector}@alpha`;
@ -224,18 +224,18 @@ module.exports = (scope, cb) => {
} }
if (scope.client.connector === 'strapi-bookshelf') { if (scope.client.connector === 'strapi-bookshelf') {
cmd += ` strapi-knex@alpha`; cmd += ' strapi-knex@alpha';
scope.additionalsDependencies = ['strapi-knex', 'knex']; scope.additionalsDependencies = ['strapi-knex', 'knex'];
} }
exec(cmd, () => { exec(cmd, () => {
if (scope.client.module) { if (scope.client.module) {
const lock = require(path.join(`${scope.tmpPath}`,`/node_modules/`,`${scope.client.module}/package.json`)); const lock = require(path.join(`${scope.tmpPath}`, '/node_modules/', `${scope.client.module}/package.json`));
scope.client.version = lock.version; scope.client.version = lock.version;
if (scope.developerMode === true && scope.client.connector === 'strapi-bookshelf') { if (scope.developerMode === true && scope.client.connector === 'strapi-bookshelf') {
const knexVersion = require(path.join(`${scope.tmpPath}`,`/node_modules/`,`knex/package.json`)); const knexVersion = require(path.join(`${scope.tmpPath}`, '/node_modules/', 'knex/package.json'));
scope.additionalsDependencies[1] = `knex@${knexVersion.version || 'latest'}`; scope.additionalsDependencies[1] = `knex@${knexVersion.version || 'latest'}`;
} }
} }
@ -248,7 +248,7 @@ module.exports = (scope, cb) => {
Promise.all(asyncFn) Promise.all(asyncFn)
.then(() => { .then(() => {
try { try {
require(path.join(`${scope.tmpPath}`,`/node_modules/`,`${scope.client.connector}/lib/utils/connectivity.js`))(scope, cb.success, connectionValidation); require(path.join(`${scope.tmpPath}`, '/node_modules/', `${scope.client.connector}/lib/utils/connectivity.js`))(scope, cb.success, connectionValidation);
} catch(err) { } catch(err) {
shell.rm('-r', scope.tmpPath); shell.rm('-r', scope.tmpPath);
cb.success(); cb.success();

View File

@ -43,8 +43,8 @@ module.exports = {
} }
try { try {
const yarnData = watcher('yarn global ls'); const yarnData = watcher('yarn global list');
isNPM = includes(yarnData, 'strapi'); isNPM = !includes(yarnData, 'strapi');
} catch(err) { } catch(err) {
isNPM = true; isNPM = true;
} }