File: .travis.yml

package info (click to toggle)
node-body-parser 1.19.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 272 kB
  • sloc: makefile: 12
file content (112 lines) | stat: -rw-r--r-- 3,070 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
language: node_js
node_js:
  - "0.8"
  - "0.10"
  - "0.12"
  - "1.8"
  - "2.5"
  - "3.3"
  - "4.9"
  - "5.12"
  - "6.17"
  - "7.10"
  - "8.16"
  - "9.11"
  - "10.15"
  - "11.14"
  - "12.0"
sudo: false
cache:
  directories:
    - node_modules
before_install:
  - |
    # Setup utility functions
    function node_version_lt () {
      [[ "$(v "$TRAVIS_NODE_VERSION")" -lt "$(v "${1}")" ]]
    }
    function npm_module_installed () {
      npm -lsp ls | grep -Fq "$(pwd)/node_modules/${1}:${1}@"
    }
    function npm_remove_module_re () {
      node -e '
        fs = require("fs");
        p = JSON.parse(fs.readFileSync("package.json", "utf8"));
        r = RegExp(process.argv[1]);
        for (k in p.devDependencies) {
          if (r.test(k)) delete p.devDependencies[k];
        }
        fs.writeFileSync("package.json", JSON.stringify(p, null, 2) + "\n");
      ' "$@"
    }
    function npm_use_module () {
      node -e '
        fs = require("fs");
        p = JSON.parse(fs.readFileSync("package.json", "utf8"));
        p.devDependencies[process.argv[1]] = process.argv[2];
        fs.writeFileSync("package.json", JSON.stringify(p, null, 2) + "\n");
      ' "$@"
    }
    function v () {
      tr '.' '\n' <<< "${1}" \
        | awk '{ printf "%03d", $0 }' \
        | sed 's/^0*//'
    }
  # Configure npm
  - |
    # Skip updating shrinkwrap / lock
    npm config set shrinkwrap false
  # Remove all non-test dependencies
  - |
    # Remove benchmark dependencies
    npm_remove_module_re '(^|-)benchmark$'
    npm_remove_module_re '^fast-url-parser$'
  # Setup Node.js version-specific dependencies
  - |
    # Configure eslint for linting
    if node_version_lt '6.0'; then npm_remove_module_re '^eslint(-|$)'
    fi
  - |
    # Configure istanbul for coverage
    if node_version_lt '0.10'; then npm_remove_module_re '^istanbul$'
    fi
  - |
    # Configure mocha for testing
    if   node_version_lt '0.10'; then npm_use_module 'mocha' '2.5.3'
    elif node_version_lt '4.0' ; then npm_use_module 'mocha' '3.5.3'
    elif node_version_lt '6.0' ; then npm_use_module 'mocha' '5.2.0'
    fi
  - |
    # Configure supertest for http calls
    if   node_version_lt '0.10'; then npm_use_module 'supertest' '1.1.0'
    elif node_version_lt '4.0' ; then npm_use_module 'supertest' '2.0.0'
    elif node_version_lt '6.0' ; then npm_use_module 'supertest' '3.4.2'
    fi
  # Update Node.js modules
  - |
    # Prune & rebuild node_modules
    if [[ -d node_modules ]]; then
      npm prune
      npm rebuild
    fi
before_scrpt:
  - |
    # Contents of node_modules
    npm -s ls ||:
script:
  - |
    # Run test script, depending on istanbul install
    if npm_module_installed 'istanbul'; then npm run-script test-travis
    else npm test
    fi
  - |
    # Run linting, if eslint exists
    if npm_module_installed 'eslint'; then npm run-script lint
    fi
after_script:
  - |
    # Upload coverage to coveralls if exists
    if [[ -e ./coverage/lcov.info ]]; then
      npm install --save-dev coveralls@2
      coveralls < ./coverage/lcov.info
    fi