update execa commands

This commit is contained in:
Mark Kaylor 2022-02-24 11:12:08 +01:00
parent fb9cbc1a23
commit 2c735db6e0
2 changed files with 6 additions and 6 deletions

View File

@ -15,7 +15,7 @@ const stopProcess = require('./stop-process');
async function getPackageInfo(packageName, { useYarn } = {}) {
// Use yarn if possible because it's faster
if (useYarn) {
const { stdout } = await execa.command(`yarn info ${packageName} --json`);
const { stdout } = await execa('yarn', ['info', packageName, '--json']);
const yarnInfo = JSON.parse(stdout);
return {
name: yarnInfo.data.name,
@ -24,7 +24,7 @@ async function getPackageInfo(packageName, { useYarn } = {}) {
}
// Fallback to npm
const { stdout } = await execa.command(`npm view ${packageName} name version --silent`);
const { stdout } = await execa('npm', ['view', packageName, 'name', 'version', '--silent']);
// Use regex to parse name and version from CLI result
const [name, version] = stdout.match(/(?<=')(.*?)(?=')/gm);
return { name, version };
@ -67,11 +67,11 @@ async function getStarterPackageInfo(starter, { useYarn } = {}) {
async function downloadNpmStarter({ name, version }, parentDir, { useYarn } = {}) {
// Download from npm, using yarn if possible
if (useYarn) {
await execa.command(`yarn add ${name}@${version} --no-lockfile --silent`, {
await execa('yarn', ['add', `${name}@${version}`, '--no-lockfile', '--silent'], {
cwd: parentDir,
});
} else {
await execa.command(`npm install ${name}@${version} --no-save --silent`, {
await execa('npm', ['install', `${name}@${version}`, '--no-save', '--silent'], {
cwd: parentDir,
});
}

View File

@ -10,7 +10,7 @@ const chalk = require('chalk');
* @returns {Object}
*/
async function getPackageInfo(packageName) {
const { stdout } = await execa.shell(`npm view ${packageName} name version --silent`);
const { stdout } = await execa('npm', ['view', packageName, 'name', 'version', '--silent']);
// Use regex to parse name and version from CLI result
const [name, version] = stdout.match(/(?<=')(.*?)(?=')/gm);
return { name, version };
@ -46,7 +46,7 @@ async function getTemplatePackageInfo(template) {
*/
async function downloadNpmTemplate({ name, version }, parentDir) {
// Download from npm
await execa.shell(`npm install ${name}@${version} --no-save --silent`, {
await execa('npm', ['install', `${name}@${version}`, '--no-save', '--silent'], {
cwd: parentDir,
});