diff --git a/package.json b/package.json index 9cc4fdae..dc783a46 100644 --- a/package.json +++ b/package.json @@ -66,6 +66,7 @@ "eslint-plugin-jasmine": "^2.1.0", "eslint-plugin-react": "^6.7.0", "jsdoc": "^3.4.0", + "license-checker": "^8.0.3", "mockery": "^2.0.0", "semver": "^5.1.0" }, diff --git a/scripts/publish.sh b/scripts/publish.sh index 1137cf9c..66abf6f1 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -62,7 +62,7 @@ git fetch origin || die 'Failed to fetch from git origin.' [ -z "$(git rev-list origin/$BRANCH..HEAD)" ] || die 'Local commits are not pushed to origin.' # Run all tests that must pass before publishing. -for test in eslint jsdoc realmjs react-example react-tests react-tests-android; do +for test in eslint jsdoc license-check realmjs react-example react-tests react-tests-android; do for configuration in Debug Release; do echo "RUNNING TEST: $test ($configuration)" echo '----------------------------------------' diff --git a/scripts/test.sh b/scripts/test.sh index 7183f448..5128da82 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -13,6 +13,8 @@ IOS_SIM_DEVICE=${IOS_SIM_DEVICE:-} # use preferentially, otherwise will be set a ios_sim_default_device_type=${IOS_SIM_DEVICE_TYPE:-iPhone 5s} ios_sim_default_ios_version=${IOS_SIM_OS:-iOS 10.1} +ACCEPTED_LICENSES='MIT, ISC, BSD, Apache-2.0, BSD-2-Clause, BSD-3-Clause, WTFPL, Unlicense, (MIT AND CC-BY-3.0)' + PATH="/opt/android-sdk-linux/platform-tools:$PATH" SRCROOT=$(cd "$(dirname "$0")/.." && pwd) XCPRETTY=$(which xcpretty || true) @@ -247,6 +249,17 @@ case "$TARGET" in npm install ./node_modules/.bin/eslint -f checkstyle . > eslint.xml || true ;; +"license-check") + [[ $CONFIGURATION == 'Debug' ]] && exit 0 + licenses=$(node_modules/.bin/license-checker --exclude "$ACCEPTED_LICENSES"); + if [[ $licenses ]]; then + echo "Unknown license detected in dependency:" + node_modules/.bin/license-checker --exclude "$ACCEPTED_LICENSES" + exit 1 + else + echo "All licenses are accepted" + fi + ;; "jsdoc") [[ $CONFIGURATION == 'Debug' ]] && exit 0 npm install