From beeaa55bd511eb8b319bf1134ec2bc151ab75bce Mon Sep 17 00:00:00 2001 From: Alberto Maturano Date: Wed, 11 Jul 2018 22:44:04 -0500 Subject: [PATCH] Fix temp directory reference for Yarn Also: fix logic detecting installation with Yarn and fix minor linter errors. related #1548 & #1463 --- packages/strapi-generate-new/lib/before.js | 10 +++++----- packages/strapi-utils/lib/packageManager.js | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/strapi-generate-new/lib/before.js b/packages/strapi-generate-new/lib/before.js index 9ad9e8c985..b22f2edca6 100755 --- a/packages/strapi-generate-new/lib/before.js +++ b/packages/strapi-generate-new/lib/before.js @@ -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(); diff --git a/packages/strapi-utils/lib/packageManager.js b/packages/strapi-utils/lib/packageManager.js index 37f518e940..ee8e657420 100644 --- a/packages/strapi-utils/lib/packageManager.js +++ b/packages/strapi-utils/lib/packageManager.js @@ -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; }