Fixes #33 Add artifactErrorsFailBuild flag

This commit is contained in:
Nick Cipollo
2021-03-21 19:05:15 -04:00
parent 5b1448e480
commit af980963d6
15 changed files with 149 additions and 49 deletions

View File

@@ -31,23 +31,31 @@ class FileArtifactGlobber {
constructor(globber = new Globber_1.FileGlobber()) {
this.globber = globber;
}
globArtifactString(artifact, contentType) {
globArtifactString(artifact, contentType, throwsWhenNoFiles) {
return artifact.split(',')
.map(path => FileArtifactGlobber.expandPath(path))
.map(pattern => this.globPattern(pattern))
.map(pattern => this.globPattern(pattern, throwsWhenNoFiles))
.reduce((accumulated, current) => accumulated.concat(current))
.map(path => new Artifact_1.Artifact(path, contentType));
}
globPattern(pattern) {
globPattern(pattern, throwsWhenNoFiles) {
const paths = this.globber.glob(pattern);
if (paths.length == 0) {
FileArtifactGlobber.reportGlobWarning(pattern);
if (throwsWhenNoFiles) {
FileArtifactGlobber.throwGlobError(pattern);
}
else {
FileArtifactGlobber.reportGlobWarning(pattern);
}
}
return paths;
}
static reportGlobWarning(pattern) {
core.warning(`Artifact pattern :${pattern} did not match any files`);
}
static throwGlobError(pattern) {
throw Error(`Artifact pattern :${pattern} did not match any files`);
}
static expandPath(path) {
return untildify_1.default(path);
}