mirror of
https://github.com/strapi/strapi.git
synced 2025-09-22 14:59:07 +00:00
async execa shells
This commit is contained in:
parent
9f39e0220c
commit
93ad75c493
@ -9,8 +9,8 @@ const chalk = require('chalk');
|
|||||||
* @param {string} packageName - Name to look up on npm, may include a specific version
|
* @param {string} packageName - Name to look up on npm, may include a specific version
|
||||||
* @returns {Object}
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
function getPackageInfo(packageName) {
|
async function getPackageInfo(packageName) {
|
||||||
const { stdout } = execa.shellSync(`npm view ${packageName} name version --silent`);
|
const { stdout } = await execa.shell(`npm view ${packageName} name version --silent`);
|
||||||
// Use regex to parse name and version from CLI result
|
// Use regex to parse name and version from CLI result
|
||||||
const [name, version] = stdout.match(/(?<=')(.*?)(?=')/gm);
|
const [name, version] = stdout.match(/(?<=')(.*?)(?=')/gm);
|
||||||
return { name, version };
|
return { name, version };
|
||||||
@ -24,7 +24,7 @@ async function getTemplatePackageInfo(template) {
|
|||||||
// Check if template is a shorthand
|
// Check if template is a shorthand
|
||||||
try {
|
try {
|
||||||
const longhand = `@strapi/template-${template}`;
|
const longhand = `@strapi/template-${template}`;
|
||||||
const packageInfo = getPackageInfo(longhand);
|
const packageInfo = await getPackageInfo(longhand);
|
||||||
// Hasn't crashed so it is indeed a shorthand
|
// Hasn't crashed so it is indeed a shorthand
|
||||||
return packageInfo;
|
return packageInfo;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -44,9 +44,9 @@ async function getTemplatePackageInfo(template) {
|
|||||||
* @param {string} packageInfo.version
|
* @param {string} packageInfo.version
|
||||||
* @param {string} parentDir - Path inside of which we install the template.
|
* @param {string} parentDir - Path inside of which we install the template.
|
||||||
*/
|
*/
|
||||||
function downloadNpmTemplate({ name, version }, parentDir) {
|
async function downloadNpmTemplate({ name, version }, parentDir) {
|
||||||
// Download from npm
|
// Download from npm
|
||||||
execa.shellSync(`npm install ${name}@${version} --no-save --silent`, {
|
await execa.shell(`npm install ${name}@${version} --no-save --silent`, {
|
||||||
cwd: parentDir,
|
cwd: parentDir,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ module.exports = async function mergeTemplate(scope, rootPath) {
|
|||||||
|
|
||||||
// Download template repository to a temporary directory
|
// Download template repository to a temporary directory
|
||||||
templateParentPath = await fse.mkdtemp(path.join(os.tmpdir(), 'strapi-'));
|
templateParentPath = await fse.mkdtemp(path.join(os.tmpdir(), 'strapi-'));
|
||||||
templatePath = downloadNpmTemplate(templatePackageInfo, templateParentPath);
|
templatePath = await downloadNpmTemplate(templatePackageInfo, templateParentPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the template is compatible with this version of strapi
|
// Make sure the template is compatible with this version of strapi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user