Skip to content

Commit

Permalink
Add some missing 'return' statements
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyrkan committed Oct 17, 2018
1 parent 0161000 commit bcabda6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions scripts/force-lowest-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function getLowestVersion(dependency, range) {
(error, stdout) => {
if (error) {
reject(`Could not retrieve versions list for "${dependency}@${range}"`);
return;
}

const versions = stdout
Expand All @@ -28,6 +29,7 @@ function getLowestVersion(dependency, range) {

if (versions.length === 0) {
reject(`Could not find a lowest version for "${dependency}@${range}"`);
return;
}

const parts = versions[0].split(' ');
Expand All @@ -36,13 +38,15 @@ function getLowestVersion(dependency, range) {
// is directly printed as the output of npm view.
if (parts.length === 1) {
resolve([dependency, parts[0]]);
return;
}

// If multiple versions are available then it outputs
// multiple lines matching the following format:
// <package>@<version> '<version>'
if (parts.length === 2) {
resolve([dependency, parts[1].replace(/'/g, '')]);
return;
}

reject(`Unexpected response for "${dependency}@${range}": ${versions[0]}`);
Expand Down Expand Up @@ -98,6 +102,7 @@ fs.readFile('package.json', (error, data) => {
fs.writeFile('package.json', JSON.stringify(packageInfo, null, 2), (error) => {
if (error) {
reject(error);
return;
}

resolve();
Expand Down

0 comments on commit bcabda6

Please sign in to comment.