mirror of
https://github.com/ScoopInstaller/Scoop.git
synced 2026-09-24 22:36:05 +00:00
Persistence: prevent NPM from overwriting node_modules by setting read-only attribute on the persisted directory junction.
This commit is contained in:
+2
-1
@@ -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/",
|
||||
|
||||
+5
-4
@@ -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 #
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user