Skip to content
This repository has been archived by the owner on Mar 30, 2021. It is now read-only.

Fixed - Do not check for version if user enters latest #37

Merged
merged 1 commit into from
Aug 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions generators/app/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ validators.packageName = async function(props) {

validators.version = async function(props, answers) {
if (props) {
if (props === "latest") {
return true;
}

let command = "npm view " + answers.packageName + "@" + props;
let res = await executeCommand(command, "version")
.then(() => {
Expand All @@ -95,6 +99,28 @@ validators.version = async function(props, answers) {

validators.checkVersionAndInstallComponent = async function(props, answers) {
if (props) {
if (props === "latest") {
let res = await executeCommand(
"cd " +
projectDirectory +
" && npm i " +
answers.packageNameToInstallComponent +
"@" +
props +
" --save-exact",
"checkVersionAndInstallComponent"
)
.then(() => true)
.catch(err => {
return chalk.red(
`Oops! We encountered an error. Please see below for the more details - \n${chalk.yellow(
err
)}`
);
});
return res;
}

let command =
"npm view " + answers.packageNameToInstallComponent + "@" + props;
let res = await executeCommand(command, "version")
Expand Down