#!/bin/sh
set -e

echo 'link'
pkgjs-utils link_external_modules
pkgjs-utils link_internal_modules
pkgjs-utils link_build_modules

egrep -v '^[[:space:]]*$|^#' debian/nodejs/testable | grep '^packages' | sort -u |
while IFS= read -r dir; do
        printf "Readline ${dir}\n"
        p=${dir%% *}
        option=${dir#* }
        [ "$p" = "$option" ] && option=""
        internal=$(printf "%s" "$p" | sed 's#^packages/#@jupyterlab/#')
        rm -rf "node_modules/$internal"
        pkgjs-ln $(printf "%s" "$p" | sed 's#^packages/#@jupyterlab/#')
done

echo 'fast build'
debian/nodejs/build

echo 'test'
debian/nodejs/test


