Skip to content

Commit

Permalink
Merge pull request #13 from mhdawson/use-find-node-application
Browse files Browse the repository at this point in the history
use shared libnodejs function to find applications
  • Loading branch information
TisVictress authored Jul 24, 2023
2 parents 859f087 + c58cb0d commit 8a9043a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
11 changes: 2 additions & 9 deletions detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,13 @@ import (
"path/filepath"

"github.com/paketo-buildpacks/libnodejs"
nodestart "github.com/paketo-buildpacks/node-start"
"github.com/paketo-buildpacks/packit/v2"
)

// functionality from node-start
func nodeApplicationExists(workingDir string, applicationFinder nodestart.ApplicationFinder) (path string, err error) {
return applicationFinder.Find(workingDir, os.Getenv("BP_LAUNCHPOINT"), os.Getenv("BP_NODE_PROJECT_PATH"))
}

func Detect() packit.DetectFunc {
return func(context packit.DetectContext) (packit.DetectResult, error) {
// likely move these to main.go ?
workingDir := context.WorkingDir
nodeApplicationFinder := nodestart.NewNodeApplicationFinder()

projectPath, err := libnodejs.FindProjectPath(context.WorkingDir)
if err != nil {
Expand All @@ -32,13 +25,13 @@ func Detect() packit.DetectFunc {

if err != nil || !pkg.HasStartScript() {
// no package.json so look for Node.js application files
path, err := nodeApplicationExists(workingDir, nodeApplicationFinder)
path, err := libnodejs.FindNodeApplication(workingDir)
if err != nil {
return packit.DetectResult{}, err
}
// if no application was found then we don't need to provide node
if path == "" {
return packit.DetectResult{}, packit.Fail.WithMessage("Node a Node.js application")
return packit.DetectResult{}, packit.Fail.WithMessage("Not a Node.js application")
}
}

Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/BurntSushi/toml v1.3.2
github.com/Masterminds/semver/v3 v3.2.1
github.com/onsi/gomega v1.27.8
github.com/paketo-buildpacks/libnodejs v0.0.2
github.com/paketo-buildpacks/libnodejs v0.1.0
github.com/paketo-buildpacks/node-start v1.0.11
github.com/paketo-buildpacks/packit/v2 v2.11.0
github.com/sclevine/spec v1.4.0
Expand All @@ -18,7 +18,7 @@ require (
github.com/paketo-buildpacks/libreload-packit v0.0.1 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/ulikunitz/xz v0.5.11 // indirect
golang.org/x/net v0.11.0 // indirect
golang.org/x/text v0.10.0 // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/text v0.11.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
7 changes: 7 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1658,6 +1658,8 @@ github.com/opencontainers/selinux v1.11.0/go.mod h1:E5dMC3VPuVvVHDYmi78qvhJp8+M5
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/paketo-buildpacks/libnodejs v0.0.2 h1:3pPWg0b2uzaPkKNqVRT3dCGJ6XheuMZpJw8mBp/bYLc=
github.com/paketo-buildpacks/libnodejs v0.0.2/go.mod h1:D69iwG2Uu9Y0VHOrs2xDk9Oy91qMo9j+gLaRwP2jINw=
github.com/paketo-buildpacks/libnodejs v0.1.0 h1:MaZXwK5QOn2pwrVya2i2PogQDo8n8pFefCvZIjGHo2U=
github.com/paketo-buildpacks/libnodejs v0.1.0/go.mod h1:6zYvjp6d0mw2Sw/3ITF1CTk7dLQigpI37QGoG2IFeRE=
github.com/paketo-buildpacks/libreload-packit v0.0.1 h1:K1HhNAqBSzRpefwGOcvdchZwyeNTgNJL9SC7V4paYt8=
github.com/paketo-buildpacks/libreload-packit v0.0.1/go.mod h1:ZWE3U94Z18yJk8Pc1mP852l9phQsrsZ+An2U98g0rWw=
github.com/paketo-buildpacks/node-start v1.0.11 h1:vg9ElyYhyxj4m5m6yEWTjKPS/9VVtUoQKamY+TuVJOc=
Expand Down Expand Up @@ -2239,6 +2241,8 @@ golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU=
golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ=
golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50=
golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down Expand Up @@ -2436,6 +2440,7 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s=
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
Expand Down Expand Up @@ -2467,6 +2472,8 @@ golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58=
golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down

0 comments on commit 8a9043a

Please sign in to comment.