nix: Reset node_modules when Yarn deps change
Signed-off-by: Pedro Pombeiro <pombeirp@users.noreply.github.com>
This commit is contained in:
parent
44bc306823
commit
bdc0ba2680
|
@ -22,12 +22,17 @@ deps="$1"
|
|||
nodeModulesDir="$STATUS_REACT_HOME/node_modules"
|
||||
|
||||
needCopyModules=1
|
||||
sentinelFilePath="$nodeModulesDir/.copied~"
|
||||
|
||||
# Check if node_modules exists and is valid
|
||||
if [ -d "$nodeModulesDir" ]; then
|
||||
if [ -f "$nodeModulesDir/.copied~" ]; then
|
||||
if [ -f "$sentinelFilePath" ]; then
|
||||
existingPath="$(cat $sentinelFilePath)"
|
||||
if [ "${existingPath}" != "${deps}" ]; then
|
||||
echo "Yarn modules changed, copying over new version"
|
||||
else
|
||||
echo "Checking for modifications in node_modules..."
|
||||
modifiedFiles=( $(find $nodeModulesDir -writable -type f -newer $nodeModulesDir/.copied~ \
|
||||
modifiedFiles=( $(find $nodeModulesDir -writable -type f -newer $sentinelFilePath \
|
||||
-not \( -path "$nodeModulesDir/react-native/third-party/*" -prune \
|
||||
-o -path "$nodeModulesDir/react-native/ReactAndroid/build/*" -prune \
|
||||
-o -path "$nodeModulesDir/*/android/build/*" -prune \
|
||||
|
@ -40,7 +45,8 @@ if [ -d "$nodeModulesDir" ]; then
|
|||
echo "Modifications detected in ${#modifiedFiles[@]} files:\n${modifiedFiles[@]}"
|
||||
fi
|
||||
fi
|
||||
if [ $needCopyModules -eq 1 ]; then
|
||||
fi
|
||||
if [ $needCopyModules -eq 1 ] && [ -d $nodeModulesDir ]; then
|
||||
chmod u+w -R $nodeModulesDir
|
||||
rm -rf $nodeModulesDir
|
||||
fi
|
||||
|
@ -69,7 +75,7 @@ if [ ! -d "$nodeModulesDir" ]; then
|
|||
time cp -HRf --preserve=all ${deps}/node_modules/. "$nodeModulesDir.tmp"
|
||||
chmod -R u+w "$nodeModulesDir.tmp"
|
||||
mv -f "$nodeModulesDir.tmp" $nodeModulesDir
|
||||
touch $nodeModulesDir/.copied~
|
||||
echo -n "${deps}" > $sentinelFilePath
|
||||
trap - ERR INT HUP
|
||||
echo "Done"
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue