<commit_before>#!/usr/bin/env bash

PKGLINK_EXEC="$1"

set -e
set -x

unamestr=$(uname)

# cwd should be here in fixtures
rimraf REFS.json
rimraf projects/foo2
rimraf projects/foo3
rimraf projects/bar1
rimraf projects/cat1

# single dir runs
rimraf projects/foo2
cp -a projects/foo1 projects/foo2
${PKGLINK_EXEC} -vr REFS.json projects/foo1 | tee output.log
grep "pkgs: 21 saved: 0" output.log
${PKGLINK_EXEC} -vr REFS.json projects/foo2 | tee output.log
grep "pkgs: 21 saved: 3.88MB" output.log
grep "define-properties" REFS.json

# combined multi-dir runs
rimraf projects/foo3
cp -a projects/foo1 projects/foo3
${PKGLINK_EXEC} -vr REFS.json -d projects/foo1 projects/foo3 | tee output.log
grep "# pkgs: 42 would save: 3.88MB" output.log
${PKGLINK_EXEC} -vr REFS.json -g projects/foo1 projects/foo3 | tee output.log
grep "# pkgs: 42 would save: 3.88MB" output.log
${PKGLINK_EXEC} -vr REFS.json projects/foo1 projects/foo3 | tee output.log
grep "pkgs: 42 saved: 3.88MB" output.log

# combined projects run picks up projects/bar1 (expect ver different)
rimraf projects/bar1
cp -a projects/foo1 projects/bar1
cd projects/bar1
npm install -S expect@1.20.1 --no-shrinkwrap
cd -
${PKGLINK_EXEC} -vr REFS.json -d projects | tee output.log
grep "# pkgs: 84 would save: 3.68MB" output.log
${PKGLINK_EXEC} -vr REFS.json -g projects | tee output.log
grep "# pkgs: 84 would save: 3.68MB" output.log
${PKGLINK_EXEC} -vr REFS.json projects | tee output.log
grep "pkgs: 84 saved: 3.68MB" output.log

# different modified time excluded
rimraf projects/cat1
cp -a projects/foo1 projects/cat1
if [[ "$unamestr" =~ _NT ]] ; then  # windows can't do modtime
  ${PKGLINK_EXEC} -vr REFS.json projects | tee output.log
  grep "pkgs: 105 saved: 3.88MB" output.log
else # non-windows, test modtime excluded
  touch projects/cat1/node_modules/expect/lib/Expectation.js
  ${PKGLINK_EXEC} -vr REFS.json -d projects | tee output.log
  grep "# pkgs: 105 would save: 3.87MB" output.log
  ${PKGLINK_EXEC} -vr REFS.json -g projects | tee output.log
  grep "# pkgs: 105 would save: 3.87MB" output.log<commit_msg>dependency size must have changed slightly, so correct<commit_after>#!/usr/bin/env bash

PKGLINK_EXEC="$1"

set -e
set -x

unamestr=$(uname)

# cwd should be here in fixtures
rimraf REFS.json
rimraf projects/foo2
rimraf projects/foo3
rimraf projects/bar1
rimraf projects/cat1

# single dir runs
rimraf projects/foo2
cp -a projects/foo1 projects/foo2
${PKGLINK_EXEC} -vr REFS.json projects/foo1 | tee output.log
grep "pkgs: 21 saved: 0" output.log
${PKGLINK_EXEC} -vr REFS.json projects/foo2 | tee output.log
grep "pkgs: 21 saved: 3.88MB" output.log
grep "define-properties" REFS.json

# combined multi-dir runs
rimraf projects/foo3
cp -a projects/foo1 projects/foo3
${PKGLINK_EXEC} -vr REFS.json -d projects/foo1 projects/foo3 | tee output.log
grep "# pkgs: 42 would save: 3.88MB" output.log
${PKGLINK_EXEC} -vr REFS.json -g projects/foo1 projects/foo3 | tee output.log
grep "# pkgs: 42 would save: 3.88MB" output.log
${PKGLINK_EXEC} -vr REFS.json projects/foo1 projects/foo3 | tee output.log
grep "pkgs: 42 saved: 3.88MB" output.log

# combined projects run picks up projects/bar1 (expect ver different)
rimraf projects/bar1
cp -a projects/foo1 projects/bar1
cd projects/bar1
npm install -S expect@1.20.1 --no-shrinkwrap
cd -
${PKGLINK_EXEC} -vr REFS.json -d projects | tee output.log
grep "# pkgs: 84 would save: 3.67MB" output.log
${PKGLINK_EXEC} -vr REFS.json -g projects | tee output.log
grep "# pkgs: 84 would save: 3.67MB" output.log
${PKGLINK_EXEC} -vr REFS.json projects | tee output.log
grep "pkgs: 84 saved: 3.67MB" output.log

# different modified time excluded
rimraf projects/cat1
cp -a projects/foo1 projects/cat1
if [[ "$unamestr" =~ _NT ]] ; then  # windows can't do modtime
  ${PKGLINK_EXEC} -vr REFS.json projects | tee output.log
  grep "pkgs: 105 saved: 3.88MB" output.log
else # non-windows, test modtime excluded
  touch projects/cat1/node_modules/expect/lib/Expectation.js
  ${PKGLINK_EXEC} -vr REFS.json -d projects | tee output.log
  grep "# pkgs: 105 would save: 3.87MB" output.log
  ${PKGLINK_EXEC} -vr REFS.json -g projects | tee output.log
  grep "# pkgs: 105 would save: 3.87MB" output.log
{'fraction_non_alphanumeric': 0.11645629911883781, 'fraction_numerical': 0.04191474160514408, 'mean_word_length': 4.147058823529412, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2106565', 'n_tokens_mistral': 1676, 'n_tokens_neox': 1538, 'n_words': 486}