[Starter CLI] fix has-yarn (#10532)

* fix missing function call

* fix deprecated execa command
This commit is contained in:
markkaylor 2021-06-23 14:00:57 +02:00 committed by GitHub
parent aebdb33a6e
commit a860d74a35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 5 deletions

View File

@ -33,7 +33,7 @@ function readStarterJson(filePath, starterUrl) {
* @param {string} projectName Name of the project
*/
async function initPackageJson(rootPath, projectName) {
const packageManager = hasYarn ? 'yarn --cwd' : 'npm run --prefix';
const packageManager = hasYarn() ? 'yarn --cwd' : 'npm run --prefix';
try {
await fse.writeJson(

View File

@ -9,7 +9,7 @@ const logger = require('./logger');
* @param {string} path Path to directory (frontend, backend)
*/
function runInstall(path) {
if (hasYarn) {
if (hasYarn()) {
return execa('yarn', ['install'], {
cwd: path,
stdin: 'ignore',
@ -20,7 +20,7 @@ function runInstall(path) {
}
function runApp(rootPath) {
if (hasYarn) {
if (hasYarn()) {
return execa('yarn', ['develop'], {
stdio: 'inherit',
cwd: rootPath,

View File

@ -4,8 +4,9 @@ const execa = require('execa');
module.exports = function hasYarn() {
try {
const { code } = execa.shellSync('yarnpkg --version');
if (code === 0) return true;
const { exitCode } = execa.sync('yarn --version', { shell: true });
if (exitCode === 0) return true;
return false;
} catch (err) {
return false;