#!/bin/sh

# Create the exported directory
mkdir -p build

if [ "$1" = "alpine" ]; then
	REGEX='\./\(api\|services\|packages\)/[^/]\+/\(package.json\|node_modules\)'
else
	REGEX='\./\(api\|services\|packages\)/[^/]+/\(package.json\|node_modules\)'
fi

# Locate services/packages and grab only the dependencies + package.json
for file in $(find . -regex $REGEX); do
	echo $file;
	cp --parents -R $file build;
done
