diff --git a/bucket/nodejs.json b/bucket/nodejs.json index 74e4a84b3..4368445c6 100644 --- a/bucket/nodejs.json +++ b/bucket/nodejs.json @@ -13,9 +13,10 @@ } }, "env_add_path": "nodejs", + "persist": "nodejs/node_modules", "post_install": " # Remove npmrc that makes global modules get installed in AppData\\Roaming\\npm -rm $dir\\nodejs\\node_modules\\npm\\npmrc +if(test-path $dir\\nodejs\\node_modules\\npm\\npmrc) { rm $dir\\nodejs\\node_modules\\npm\\npmrc } npm update -g", "checkver": { "url": "https://nodejs.org/en/download/current/", diff --git a/lib/install.ps1 b/lib/install.ps1 index 240d02caf..5b533a787 100644 --- a/lib/install.ps1 +++ b/lib/install.ps1 @@ -966,19 +966,19 @@ function persist_def($persist) { function persist_data($manifest) { $persist = $manifest.persist if($persist) { - ensure $data_dir + $data_dir = ensure $data_dir if ($persist -is [String]) { $persist = @($persist); } - write-host "Persisting data..." + write-host "Persisting $persist" $persist | % { $source, $target = persist_def $_ # add base paths - $source = "$original_dir\$source" - $target = "$data_dir\$target" + $source = "$(resolve-path $original_dir\$source)" + $target = fullpath "$data_dir\$target" # TODO test with files if (!(test-path $target)) { @@ -997,6 +997,7 @@ function persist_data($manifest) { # create link # TODO use /h for files cmd /c "mklink /j $source $target" | out-null + attrib $source +R /L # } } }