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);
// Manually create the temp directory for yarn
if (!isStrapiInstalledWithNPM) {
shell.exec('mkdir tmp');
shell.exec(`mkdir ${scope.tmpPath}`);
}
let cmd = `${packageCmd} ${scope.client.connector}@alpha`;
@ -224,18 +224,18 @@ module.exports = (scope, cb) => {
}
if (scope.client.connector === 'strapi-bookshelf') {
cmd += ` strapi-knex@alpha`;
cmd += ' strapi-knex@alpha';
scope.additionalsDependencies = ['strapi-knex', 'knex'];
}
exec(cmd, () => {
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;
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'}`;
}
}
@ -248,7 +248,7 @@ module.exports = (scope, cb) => {
Promise.all(asyncFn)
.then(() => {
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) {
shell.rm('-r', scope.tmpPath);
cb.success();

View File

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