Просмотр исходного кода

fix for script install cypress

philippe 6 лет назад
Родитель
Сommit
47b8305ce6
3 измененных файлов: 46 добавлений и 5 удалений
  1. 5 0
      bash_library.sh
  2. 6 0
      functionnal_tests/cypress.json.sample
  3. 35 5
      install_cypress.sh

+ 5 - 0
bash_library.sh Просмотреть файл

@@ -2,8 +2,13 @@
2 2
 
3 3
 YELLOW='\033[1;33m'
4 4
 BROWN='\033[0;33m'
5
+GREEN='\033[1;32m'
5 6
 NC='\033[0m' # No Color
6 7
 
7 8
 function log {
8 9
     echo -e "\n${YELLOW}[$(date +'%H:%M:%S')]${BROWN} $ $1${NC}"
9 10
 }
11
+
12
+function loggood {
13
+    echo -e "\n${YELLOW}[$(date +'%H:%M:%S')]${GREEN} $ $1${NC}"
14
+} 

+ 6 - 0
functionnal_tests/cypress.json.sample Просмотреть файл

@@ -0,0 +1,6 @@
1
+{
2
+  "baseUrl": "http://localhost:6543",
3
+  "viewportWidth": 1280,
4
+  "viewportHeight": 1024,
5
+  "integrationFolder": "{path_test_file}"
6
+}

+ 35 - 5
install_cypress.sh Просмотреть файл

@@ -8,26 +8,56 @@
8 8
   dpkg -l | grep '^ii' | grep 'nodejs\s'
9 9
 
10 10
   if [ $? -eq 0 ]; then
11
-    log "nodjs is installed"
11
+    loggood "nodejs is installed"
12 12
   else
13 13
     log "install nodejs"
14 14
     sudo apt install curl
15 15
     curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
16 16
     sudo apt install -y nodejs
17
+    loggood "nodejs is now installed"
17 18
   fi
18 19
 )
19 20
 
20 21
 # install Cypress
21
-
22
+log "go to functionnal_tests subdir.."
23
+cd  functionnal_tests || exit 1;
22 24
 (
23
-  log "go to functionnal_tests subdir.."
24
-  cd  functionnal_tests || exit 1;
25
+  ACTUALDIR=$(pwd)
26
+  loggood "Your are now here: \"$ACTUALDIR\""
25 27
   log "check if package.json exist"
26 28
   if [ ! -f package.json ]; then
27
-    log "run npm init"
29
+    log "package.json not exist => run npm init"
28 30
     npm init -y
31
+    loggood "npm init finished => package.json is now created"
32
+  else
33
+    loggood "package.json exist"
29 34
   fi
30 35
   log "install cypress"
31 36
   npm install cypress --save-dev
37
+  loggood "cypress is now installed"
32 38
 )
33 39
 
40
+# modify cypress.json
41
+
42
+(
43
+  log "check if cypress.json exist"
44
+  if [ ! -f cypress.json ]; then
45
+    log "cypress.json not exist => copy from cypress.json.sample"
46
+    cp cypress.json.sample cypress.json
47
+    loggood "cypress.json is now available"
48
+    log "write path in cypress.json"
49
+    SUBDIR=$(pwd)
50
+    sed -i "s|{path_test_file}|$SUBDIR|g" cypress.json
51
+    loggood "path is now configured"
52
+  else
53
+  log "cypress.json exist => check if integrationFolder have path"
54
+    if grep -q "\"integrationFolder\"\:\s\"{path_test_file}\"" cypress.json ; then
55
+      log "no path => write path in cypress.json"
56
+      SUBDIR=$(pwd)
57
+      sed -i "s|{path_test_file}|$SUBDIR|g" cypress.json
58
+      loggood "path is now configured"
59
+    else
60
+      loggood "path exist. Modify manualy if necessary"
61
+    fi
62
+  fi
63
+)