From 55580067bbc14909f926f03318744d915a009f0c Mon Sep 17 00:00:00 2001 From: Michael Dawson Date: Thu, 13 Jul 2023 18:20:43 -0400 Subject: [PATCH] use libnodejs function to resolve nodejs version Signed-off-by: Michael Dawson --- build.go | 10 ++-------- go.mod | 1 + go.sum | 2 ++ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/build.go b/build.go index 78de7404..59909f09 100644 --- a/build.go +++ b/build.go @@ -13,6 +13,7 @@ import ( "github.com/paketo-buildpacks/packit/v2/postal" "github.com/paketo-buildpacks/packit/v2/sbom" "github.com/paketo-buildpacks/packit/v2/scribe" + "github.com/paketo-buildpacks/libnodejs" ) //go:generate faux --interface EntryResolver --output fakes/entry_resolver.go @@ -67,14 +68,7 @@ func Build(entryResolver EntryResolver, dependencyManager DependencyManager, sbo logger.Process("Resolving Node Engine version") - priorities := []interface{}{ - "BP_NODE_VERSION", - "package.json", - ".nvmrc", - ".node-version", - } - - entry, allEntries := entryResolver.Resolve("node", context.Plan.Entries, priorities) + entry, allEntries := libnodejs.ResolveNodeVersion(entryResolver.Resolve, context.Plan) if entry.Name == "" && len(allEntries) == 0 { logger.Process("Node no longer requested by plan, satisfied by extension") diff --git a/go.mod b/go.mod index a1e1db91..de1738cb 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( github.com/BurntSushi/toml v1.3.2 github.com/Masterminds/semver/v3 v3.2.1 github.com/onsi/gomega v1.27.10 + github.com/paketo-buildpacks/libnodejs v0.2.0 github.com/paketo-buildpacks/occam v0.17.0 github.com/paketo-buildpacks/packit/v2 v2.11.0 github.com/sclevine/spec v1.4.0 diff --git a/go.sum b/go.sum index 048e522d..bab5e15c 100644 --- a/go.sum +++ b/go.sum @@ -2568,6 +2568,8 @@ github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6 github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= +github.com/paketo-buildpacks/libnodejs v0.2.0 h1:y7G6BQIeeMUnIlzREiAipQlAcaXJ82VMPldkTTiv9o4= +github.com/paketo-buildpacks/libnodejs v0.2.0/go.mod h1:JLs6tu5TD6la8p1IKo3UYO1C93/ywGesa74FpM82wPw= github.com/paketo-buildpacks/occam v0.17.0 h1:2Xt4Vc4MbSAsLyu+WLttd6gpR4ORsBwcoqAfWz4QaD4= github.com/paketo-buildpacks/occam v0.17.0/go.mod h1:OfGaY+04G+zPoX3HVnMj3dXnBkFEjPC3UyM8eAIeBqk= github.com/paketo-buildpacks/packit/v2 v2.6.1/go.mod h1:iBArWOfC5xZQF01o+zwnVKS+/hUBuFG+O1jCvzqBujs=