Merge "Added reset-css node module to fix styling"
[osm/UI.git] / skyquake / scripts / handle_plugin_node_modules
1 #!/bin/bash
2
3
4 #   Copyright 2016 RIFT.IO Inc
5 #
6 #   Licensed under the Apache License, Version 2.0 (the "License");
7 #   you may not use this file except in compliance with the License.
8 #   You may obtain a copy of the License at
9 #
10 #       http://www.apache.org/licenses/LICENSE-2.0
11 #
12 #   Unless required by applicable law or agreed to in writing, software
13 #   distributed under the License is distributed on an "AS IS" BASIS,
14 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 #   See the License for the specific language governing permissions and
16 #   limitations under the License.
17 #
18
19 # Unpack tar archives for plugins.  Maintain a timestamp.txt file for each, so
20 # that tar archives are only unpacked if they have been changed.
21 #
22 # This script is needed to unpack the files as cpack cannot handle a lot of files.
23
24 usage() {
25     echo "usage: $(basename ${BASH_SOURCE[0]})"
26 }
27
28 function extract_node_modules() {
29     tar xf node_modules.tar
30     touch timestamp.txt
31 }
32
33 # change to the directory of this script
34 THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
35
36 cd $THIS_DIR
37 echo "Handling plugin node modules"
38
39 cd ../plugins
40 for dir in */; do
41     echo "Checking plugin "${dir}" for newer node_modules"
42     cd ${dir}
43     if [ ! -f timestamp.txt ]; then
44         echo "timestamp file not found ... node_modules need to be expanded and timestamp needs to be touched"
45         extract_node_modules
46     else
47         echo "Checking if node_modules.tar has a newer timestamp than timestamp.txt"
48         if [[ node_modules.tar -nt timestamp.txt ]]; then
49             echo "node_modules.tar is newer than timestamp ... node modules need to be expanded and timestamp needs to be touched"
50             extract_node_modules
51         else
52             echo "node_modules.tar is older than timestamp ... nothing needs to be done"
53         fi
54     fi
55     cd ..
56     echo "Checking plugin "${dir}" for newer node_modules ...done"
57 done
58