File: .travis.yml

package info (click to toggle)
node-negotiator 0.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 208 kB
  • sloc: makefile: 2
file content (106 lines) | stat: -rw-r--r-- 3,016 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
language: node_js
node_js:
  - "0.6"
  - "0.8"
  - "0.10"
  - "0.12"
  - "1.8"
  - "2.5"
  - "3.3"
  - "4.9"
  - "5.12"
  - "6.16"
  - "7.10"
  - "8.15"
  - "9.11"
  - "10.15"
  - "11.10"
  - "12.1"
sudo: false
dist: trusty
env:
  global:
    # Suppress Node.js 0.6 compile warnings
    - "CXXCOM='$CXX -o $TARGET -c $CXXFLAGS $CCFLAGS -Wno-unused-local-typedefs -Wno-maybe-uninitialized -Wno-narrowing -Wno-strict-overflow $_CCCOMCOM $SOURCES'"
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
  # Setup Node.js version-specific dependencies
  - |
    # Configure eslint for linting
    if node_version_lt '6.0'; then npm_remove_module_re '^eslint(-|$)'
    fi
  - |
    # Configure mocha for testing
    if   node_version_lt '0.8' ; then npm_use_module 'mocha' '1.21.5'
    elif 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 nyc for testing
    if   node_version_lt '0.10'; then npm_remove_module_re '^nyc$'
    elif node_version_lt '4.0' ; then npm_use_module 'nyc' '10.3.2'
    elif node_version_lt '6.0' ; then npm_use_module 'nyc' '11.9.0'
    fi
  # Update Node.js modules
  - |
    # Prune & rebuild node_modules
    if [[ -d node_modules ]]; then
      npm prune
      npm rebuild
    fi
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, depending on eslint install
    if npm_module_installed 'eslint'; then npm run-script lint
    fi
after_script:
  - |
    # Upload coverage to coveralls if exists
    if [[ -d .nyc_output ]]; then
      npm install --save-dev coveralls@2
      nyc report --reporter=text-lcov | coveralls
    fi