Created
July 6, 2022 08:49
-
-
Save igrek8/f104830f4ad7aa7d1cd6620a5763807a to your computer and use it in GitHub Desktop.
copy production node_modules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -eo pipefail | |
node_modules=$(pwd)/node_modules | |
output="$1/nodejs/node_modules" | |
list=($(npm list --production --all --parseable)) | |
mkdir -p $output | |
for item in "${list[@]}"; do | |
path=$(realpath --relative-to="$node_modules" "$item") | |
[[ "${path}" == ".." ]] && continue | |
mkdir -p "$output/$path" | |
cp -r -d "$item" "$output/$path" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment