1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-03-03 15:02:35 +02:00

Add support for yarn (#2721)

Co-authored-by: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com>
This commit is contained in:
Sven Merk 2021-03-26 09:28:40 +01:00 committed by GitHub
parent 95ebfb3b2f
commit e4346460ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -129,7 +129,7 @@ func GetArtifact(buildTool, buildDescriptorFilePath string, opts *Options, utils
versionField: "version",
artifactIDField: "ID",
}
case "npm":
case "npm", "yarn":
if len(buildDescriptorFilePath) == 0 {
buildDescriptorFilePath = "package.json"
}

View File

@ -118,6 +118,18 @@ func TestGetArtifact(t *testing.T) {
assert.Equal(t, "semver2", npm.VersioningScheme())
})
t.Run("yarn", func(t *testing.T) {
npm, err := GetArtifact("yarn", "", &Options{VersionField: "theversion"}, nil)
assert.NoError(t, err)
theType, ok := npm.(*JSONfile)
assert.True(t, ok)
assert.Equal(t, "package.json", theType.path)
assert.Equal(t, "version", theType.versionField)
assert.Equal(t, "semver2", npm.VersioningScheme())
})
t.Run("pip", func(t *testing.T) {
fileExists = func(string) (bool, error) { return true, nil }
pip, err := GetArtifact("pip", "", &Options{}, nil)