Skip to content

Commit

Permalink
fix: improve error messages on cache init failures
Browse files Browse the repository at this point in the history
  • Loading branch information
error418 committed Sep 24, 2019
1 parent b6718c1 commit 56308f5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .releaserc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ gradle:
- '@semantic-release/release-notes-generator'
- '@semantic-release/github'
config:
registry: https://registry.npmjs.orgs/
registry: https://registry.npmjs.org/
9 changes: 7 additions & 2 deletions src/main/groovy/de/illjut/gradle/semrel/SemrelPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,13 @@ class SemrelPlugin implements Plugin<Project> {

if (!cacheCompleteMarker.exists()) { // prepare cache for faster executions
project.logger.info "preparing npm cache for faster executions."
nodeExec.executeNpm(['i', '--prefer-offline', '-D', "semantic-release@v${semanticReleaseVersion}".toString(), "@semantic-release/exec"], workDir)
cacheCompleteMarker.createNewFile()
def cacheResult = nodeExec.executeNpm(['i', '--prefer-offline', '-D', "semantic-release@v${semanticReleaseVersion}".toString(), "@semantic-release/exec"], workDir)

if (cacheResult.isSuccess()) {
cacheCompleteMarker.createNewFile()
} else {
throw new GradleScriptException("Failed to initialize NPM cache. See log for details.", new Exception("npm i failed. See details by running gradle with -i"))
}
}

def extraPackages = [ ]
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/de/illjut/gradle/semrel/ProcessResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ public ProcessResult(int exitCode, List<String> log) {
this.exitCode = exitCode;
this.log = log;
}

public boolean isSuccess() {
return exitCode == 0;
}
}

0 comments on commit 56308f5

Please sign in to comment.