diff --git a/find_node_application.go b/find_node_application.go index 3c30a8d..b9618a9 100644 --- a/find_node_application.go +++ b/find_node_application.go @@ -17,12 +17,16 @@ func FindNodeApplication(workingDir string) (string, error) { launchpoint := os.Getenv(LaunchPointEnvName) if launchpoint != "" { - if _, err := os.Stat(filepath.Join(workingDir, launchpoint)); err != nil { - if errors.Is(err, os.ErrNotExist) { - return "", fmt.Errorf("expected value derived from BP_LAUNCHPOINT [%s] to be an existing file", launchpoint) - } + doVerify := os.Getenv(VerifyLaunchPointEnvName) - return "", err + if doVerify != "false" { + if _, err := os.Stat(filepath.Join(workingDir, launchpoint)); err != nil { + if errors.Is(err, os.ErrNotExist) { + return "", fmt.Errorf("expected value derived from BP_LAUNCHPOINT [%s] to be an existing file", launchpoint) + } + + return "", err + } } return filepath.Clean(launchpoint), nil diff --git a/find_node_application_test.go b/find_node_application_test.go index 0cd70a8..be13dbb 100644 --- a/find_node_application_test.go +++ b/find_node_application_test.go @@ -259,6 +259,22 @@ func testFindNodeApplication(t *testing.T, context spec.G, it spec.S) { Expect(err).To(MatchError(ContainSubstring("expected value derived from BP_LAUNCHPOINT [./no-such-file.js] to be an existing file"))) Expect(file).To(Equal("")) }) + + it("returns the empty string and no error if BP_VERIFY_LAUNCHPOINT is true", func() { + t.Setenv("BP_LAUNCHPOINT", "./no-such-file.js") + t.Setenv("BP_VERIFY_LAUNCHPOINT", "true") + file, err := libnodejs.FindNodeApplication(workingDir) + Expect(err).To(MatchError(ContainSubstring("expected value derived from BP_LAUNCHPOINT [./no-such-file.js] to be an existing file"))) + Expect(file).To(Equal("")) + }) + + it("returns the highest priority file if BP_VERIFY_LAUNCHPOINT is false", func() { + t.Setenv("BP_LAUNCHPOINT", "./gen/no-such-file-yet.js") + t.Setenv("BP_VERIFY_LAUNCHPOINT", "false") + file, err := libnodejs.FindNodeApplication(workingDir) + Expect(err).NotTo(HaveOccurred()) + Expect(file).To(Equal(filepath.Join("gen", "no-such-file-yet.js"))) + }) }) }) diff --git a/spec_constants.go b/spec_constants.go index fd08d44..46c872c 100644 --- a/spec_constants.go +++ b/spec_constants.go @@ -2,4 +2,5 @@ package libnodejs const ProjectPathEnvName = "BP_NODE_PROJECT_PATH" const LaunchPointEnvName = "BP_LAUNCHPOINT" +const VerifyLaunchPointEnvName = "BP_VERIFY_LAUNCHPOINT" const StartScriptNameEnvName = "BP_NPM_START_SCRIPT"