This repository was archived by the owner on Dec 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlicense-check.sh
executable file
·53 lines (43 loc) · 1.68 KB
/
license-check.sh
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
#! /bin/bash -e
############################################################################
#
# (C) Copyright IBM Corp. 2018
#
# This program and the accompanying materials are made available
# under the terms of the Apache License v2.0 which accompanies
# this distribution.
#
# The Apache License v2.0 is available at
# http://www.opensource.org/licenses/apache2.0.php
#
# Contributors:
# Multiple authors (IBM Corp.) - initial implementation and documentation
############################################################################
. ./setup-nvs.sh
### Use CitGM to run custom-license-test.js on a module. ###
echo -e "\n\nParameters:\n
WORKSPACE: $WORKSPACE\n
NODE_VERSION: $NODE_VERSION\n
MODULE: $MODULE\n
MODULE_VERSION: $MODULE_VERSION\n\n"
[ -z "$NODE_VERSION" ] && echo "NODE_VERSION is undefined, bailing..." && exit 1
[ -z "$MODULE_VERSION" ] && echo "MODULE_VERSION is undefined, bailing..." && exit 1
[ -z "$MODULE" ] && echo "MODULE is undefined, bailing..." && exit 1
[ -z "$CITGM_LOGLEVEL" ] && CITGM_LOGLEVEL=info
nvs add $NODE_VERSION >/dev/null
nvs use $NODE_VERSION >/dev/null
npm install -g citgm >/dev/null
mkdir -p "$WORKSPACE/deps/node_modules"
(cd "$WORKSPACE/deps"; npm install "$WORKSPACE/deps" license-checker)
citgm --verbose "$CITGM_LOGLEVEL" --customTest "$WORKSPACE/custom-license-test.js" --lookup "$WORKSPACE/lookup.json" "$MODULE@$MODULE_VERSION"
EXIT_STATUS="$?"
if [ "$EXIT_STATUS" = "0" ]; then
nvs add 8 >/dev/null
nvs use 8 >/dev/null
npm install >/dev/null
export TOKEN=$(node fetch-token.js)
node update-license.js
else
echo -e "\n\nEXIT_STATUS: $EXIT_STATUS.\nCITGM exited with a non-zero exit code.\n\n"
exit 1
fi