Fixes #136 Globber now also supports new line as separator.
This commit is contained in:
@@ -54,7 +54,7 @@ describe("ArtifactGlobber", () => {
|
||||
expect(warnMock).not.toBeCalled()
|
||||
})
|
||||
|
||||
it("splits multiple paths", () => {
|
||||
it("splits multiple paths with comma separator", () => {
|
||||
const globber = createArtifactGlobber()
|
||||
|
||||
const expectedArtifacts =
|
||||
@@ -69,6 +69,21 @@ describe("ArtifactGlobber", () => {
|
||||
expect(warnMock).not.toBeCalled()
|
||||
})
|
||||
|
||||
it("splits multiple paths with new line separator and trims start", () => {
|
||||
const globber = createArtifactGlobber()
|
||||
|
||||
const expectedArtifacts =
|
||||
globResults
|
||||
.concat(globResults)
|
||||
.map((path) => new Artifact(path, contentType))
|
||||
|
||||
expect(globber.globArtifactString('path1\n path2', 'raw', false))
|
||||
.toEqual(expectedArtifacts)
|
||||
expect(globMock).toBeCalledWith('path1')
|
||||
expect(globMock).toBeCalledWith('path2')
|
||||
expect(warnMock).not.toBeCalled()
|
||||
})
|
||||
|
||||
it("warns when no glob results are produced and empty results shouldn't throw", () => {
|
||||
const globber = createArtifactGlobber([])
|
||||
|
||||
|
||||
@@ -33,7 +33,9 @@ class FileArtifactGlobber {
|
||||
this.globber = globber;
|
||||
}
|
||||
globArtifactString(artifact, contentType, errorsFailBuild) {
|
||||
return artifact.split(',')
|
||||
const split = /[,\n]/;
|
||||
return artifact.split(split)
|
||||
.map(path => path.trimStart())
|
||||
.map(path => FileArtifactGlobber.expandPath(path))
|
||||
.map(pattern => this.globPattern(pattern, errorsFailBuild))
|
||||
.map((globResult) => FileArtifactGlobber.validatePattern(errorsFailBuild, globResult[1], globResult[0]))
|
||||
|
||||
@@ -16,7 +16,9 @@ export class FileArtifactGlobber implements ArtifactGlobber {
|
||||
}
|
||||
|
||||
globArtifactString(artifact: string, contentType: string, errorsFailBuild: boolean): Artifact[] {
|
||||
return artifact.split(',')
|
||||
const split = /[,\n]/
|
||||
return artifact.split(split)
|
||||
.map(path => path.trimStart())
|
||||
.map(path => FileArtifactGlobber.expandPath(path))
|
||||
.map(pattern => this.globPattern(pattern, errorsFailBuild))
|
||||
.map((globResult) => FileArtifactGlobber.validatePattern(errorsFailBuild, globResult[1], globResult[0]))
|
||||
|
||||
Reference in New Issue
Block a user