Skip to content
Snippets Groups Projects
Verified Commit 6a3725eb authored by David Beniamine's avatar David Beniamine
Browse files

WIP watching subdirectoires

parent b4e7eebe
No related tags found
No related merge requests found
node_modules/
./*/node_modules/
annotot-db/
.cache
FROM debian:stable as builder
RUN apt-get update && apt-get install -y npm git
RUN apt-get update && apt-get install -y npm git jq
COPY . /opt
WORKDIR /opt
......
FROM debian:stable-slim
RUN apt-get update && apt-get install -y git npm
RUN apt-get update && apt-get install -y git npm jq inotify-tools
RUN useradd --home-dir /opt node
RUN chown node:node /opt
EXPOSE 9000
......
#!/bin/bash
declare -A SUBMODULES=(
['mirador-video-annotation']="build:es"
['annotations-plugin']="build"
)
run_on_modules(){
for mod in "${!SUBMODULES[@]}"; do
echo -e "\t$mod"
## Runs action $2 for submodule $1
watch() {
inotifywait \
--event modify \
--event create \
--event delete \
--event move \
--monitor \
--quiet \
--recursive \
--format '%e %w%f' \
./src | while read line; do
echo "$line"
$@
done
}
run() {
mod=$1
shift
echo "Running '$@' on '$mod'"
cd $mod
if [ "$1" == "install" ]; then
npm install
else
npm run ${SUBMODULES[${mod}]}
$@
if $watch; then
watch $@ &
fi
cd ..
done
}
if [ "$1" == "install" ]; then
echo "Installing submodules"
run_on_modules install
action=$1
watch=false
if [ "$action" == "watch" ]; then
action=build
watch=true
fi
echo "Compiling submodules"
run_on_modules build
echo "Submodule action '$action' triggered"
jq -r --arg action "$action" \
'.subscripts | to_entries[] | "\(.key) \(.value | .[$action])"' \
package.json | \
while read line; do
run $line
done
......@@ -4,10 +4,20 @@
"description": "",
"private": true,
"scripts": {
"preinstall": "./build_deps.sh install",
"prebuild": "./build_deps.sh build",
"build": "webpack --config webpack.config.js",
"serve": "npm install && webpack serve --config webpack.config.js"
"preserve": "./build_deps.sh watch",
"serve": "webpack serve --config webpack.config.js"
},
"subscripts": {
"annotations-plugin": {
"install": "npm install",
"build": "npm run build"
},
"mirador-video-annotation": {
"install": "npm install",
"build": "npm run build:es"
}
},
"author": "",
"license": "ISC",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment