diff --git a/build.go b/build.go index 8cbbed0a..713067d5 100644 --- a/build.go +++ b/build.go @@ -78,11 +78,13 @@ func Build(entryResolver EntryResolver, dependencyManager DependencyManager, sbo return packit.BuildResult{}, err } - nodeLayer.Launch, nodeLayer.Build, nodeLayer.Cache = true, false, false + nodeLayer.Launch, nodeLayer.Build, nodeLayer.Cache = true, true, false nodeLayer.Metadata = map[string]interface{}{ - BuildKey: false, + BuildKey: true, LaunchKey: true, } + + nodeLayer.SharedEnv.Default("NODE_HOME", "") } else { logger.Candidates(allEntries) @@ -175,6 +177,7 @@ func Build(entryResolver EntryResolver, dependencyManager DependencyManager, sbo return packit.BuildResult{}, err } } + nodeLayer.SharedEnv.Default("NODE_HOME", nodeLayer.Path) } var optimizedMemory bool @@ -182,7 +185,6 @@ func Build(entryResolver EntryResolver, dependencyManager DependencyManager, sbo optimizedMemory = true } - nodeLayer.SharedEnv.Default("NODE_HOME", nodeLayer.Path) nodeLayer.SharedEnv.Default("NODE_ENV", "production") nodeLayer.SharedEnv.Default("NODE_VERBOSE", "false") nodeLayer.SharedEnv.Default("NODE_OPTIONS", "--use-openssl-ca") diff --git a/build_test.go b/build_test.go index 5a8332d4..c1f044ce 100644 --- a/build_test.go +++ b/build_test.go @@ -466,7 +466,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { Expect(layer.Name).To(Equal("node")) Expect(layer.Path).To(Equal(filepath.Join(layersDir, "node"))) Expect(layer.SharedEnv).To(Equal(packit.Environment{ - "NODE_HOME.default": filepath.Join(layersDir, "node"), + "NODE_HOME.default": "", "NODE_ENV.default": "production", "NODE_VERBOSE.default": "false", "NODE_OPTIONS.default": "--use-openssl-ca", @@ -477,7 +477,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { })) Expect(layer.Metadata).To(Equal(map[string]interface{}{ - nodeengine.BuildKey: false, + nodeengine.BuildKey: true, nodeengine.LaunchKey: true, }))