File tree Expand file tree Collapse file tree 3 files changed +22
-12
lines changed Expand file tree Collapse file tree 3 files changed +22
-12
lines changed Original file line number Diff line number Diff line change @@ -40,9 +40,10 @@ file that looks like the following:
40
40
41
41
## Configuration
42
42
43
- | Environment Variable | Description |
44
- | -------------------------------| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
45
- | ` $BP_NPM_VERSION ` | If set, this custom version of ` npm ` will be used instead of the one provided by the ` nodejs ` installation. |
43
+ | Environment Variable | Description |
44
+ | -----------------------------| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
45
+ | ` $BP_NPM_VERSION ` | If set, this custom version of ` npm ` will be used instead of the one provided by the ` nodejs ` installation. |
46
+ | ` $BP_KEEP_NODE_BUILD_CACHE ` | If set to ` true ` (default ` false ` ), the folder ` node_modules/.cache ` will not be removed after the build, but will be readonly at runtime. |
46
47
47
48
## Usage
48
49
Original file line number Diff line number Diff line change @@ -284,16 +284,19 @@ func Build(entryResolver EntryResolver,
284
284
return packit.BuildResult {}, err
285
285
}
286
286
287
- linkName := filepath .Join (layer .Path , "node_modules" , ".cache" )
288
- err = os .RemoveAll (linkName )
289
- if err != nil {
290
- return packit.BuildResult {}, err
291
- }
287
+ keepBuildCache , _ := environment .Lookup ("BP_KEEP_NODE_BUILD_CACHE" )
288
+ if keepBuildCache != "true" {
289
+ linkName := filepath .Join (layer .Path , "node_modules" , ".cache" )
290
+ err = os .RemoveAll (linkName )
291
+ if err != nil {
292
+ return packit.BuildResult {}, err
293
+ }
292
294
293
- cacheFolder := filepath .Join (os .TempDir (), NODE_MODULES_CACHE )
294
- err = os .Symlink (cacheFolder , linkName )
295
- if err != nil {
296
- return packit.BuildResult {}, err
295
+ cacheFolder := filepath .Join (os .TempDir (), NODE_MODULES_CACHE )
296
+ err = os .Symlink (cacheFolder , linkName )
297
+ if err != nil {
298
+ return packit.BuildResult {}, err
299
+ }
297
300
}
298
301
299
302
if build {
Original file line number Diff line number Diff line change @@ -32,6 +32,11 @@ api = "0.7"
32
32
name = " BP_NPM_VERSION"
33
33
description = " configures a custom npm version"
34
34
35
+ [[metadata .configurations ]]
36
+ name = " BP_KEEP_NODE_BUILD_CACHE"
37
+ default = " false"
38
+ description = " keep the 'node_modules/.cache' folder after the build (will be readonly at runtime)'"
39
+
35
40
[[metadata .configurations ]]
36
41
name = " NODE_HOME"
37
42
description = " path the Node.js installation"
@@ -45,5 +50,6 @@ api = "0.7"
45
50
default = " error"
46
51
description = " configures npm output verbosity"
47
52
53
+
48
54
[[stacks ]]
49
55
id = " *"
You can’t perform that action at this time.
0 commit comments