diff --git a/package.json b/package.json index e3f140f9..36a2c9cf 100644 --- a/package.json +++ b/package.json @@ -44,15 +44,26 @@ "dependencies.list" ], "scripts": { - "get-version": "echo $npm_package_version", + "get-version": "node -p process.env.npm_package_version", "set-version": "scripts/set-version.sh", "get-core-version": "scripts/download-core.sh --version", "get-sync-version": "scripts/download-core.sh --versionSync", - "jsdoc": "rm -rf docs/output && jsdoc -u docs/tutorials -p package.json -c docs/conf.json", "lint": "eslint", "test": "scripts/test.sh", "install": "node-pre-gyp install --fallback-to-build", - "prepublish": "node scripts/prepublish.js" + "prepublish": "node scripts/prepublish.js", + "eslint": "npm install && npm run lint .", + "license-check": "npm install && license-checker --exclude \"MIT,ISC,BSD,Apache-2.0,BSD-2-Clause,BSD-3-Clause,WTFPL,Unlicense,(MIT AND CC-BY-3.0)\" | node scripts/handle-license-check.js", + "jsdoc:clean": "rimraf ./docs/output", + "jsdoc": "npm install && npm run jsdoc:clean && jsdoc -c docs/conf.json", + "node-tests": "npm install --build-from-source && cd tests && npm install && npm run test-nosync && cd ..", + "node-nosync-tests": "npm install --build-from-source && cd tests && npm install && npm run test-nosync && cd ..", + "test-runner:ava" :"cd tests/test-runners/ava && npm install && npm test", + "test-runner:mocha" :"cd tests/test-runners/mocha && npm install && npm test", + "test-runner:jest" :"cd tests/test-runners/jest && npm install && npm test", + "test-runners" : "npm run test-runner:ava && npm run test-runner:mocha && npm run test-runner:jest", + "isMac" : "node -p \"if (process.platform == 'darwin') { process.exit(0); } else { process.exit(-1); }\"", + "testMac" : "npm run isMac -s && echo this is mac || echo . " }, "dependencies": { "extract-zip": "^1.6.0", @@ -72,6 +83,7 @@ "jsdoc": "^3.4.0", "license-checker": "^8.0.3", "mockery": "^2.0.0", + "rimraf": "^2.6.1", "semver": "^5.1.0" }, "rnpm": { diff --git a/scripts/handle-license-check.js b/scripts/handle-license-check.js new file mode 100644 index 00000000..bacdca73 --- /dev/null +++ b/scripts/handle-license-check.js @@ -0,0 +1,19 @@ +#!/usr/bin/env node + +process.stdin.resume(); +process.stdin.setEncoding('utf8'); + +var licenseCheckerResult; + +process.stdin.on('data', function(data) { + licenseCheckerResult += data; +}); + +process.stdin.on('end', function() { + if (!licenseCheckerResult) { + console.log("All licenses are accepted"); + } else { + console.error("Unknown license detected in dependency:"); + console.error(licenseCheckerResult); + } +}); \ No newline at end of file diff --git a/scripts/test.sh b/scripts/test.sh index 4becaf74..cdfcfa73 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -245,8 +245,7 @@ rm -rf ~/.yarn-cache/npm-realm-* case "$TARGET" in "eslint") [[ $CONFIGURATION == 'Debug' ]] && exit 0 - npm install - npm run lint . + npm run eslint ;; "eslint-ci") [[ $CONFIGURATION == 'Debug' ]] && exit 0 @@ -255,18 +254,10 @@ case "$TARGET" in ;; "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 + npm run license-check ;; "jsdoc") [[ $CONFIGURATION == 'Debug' ]] && exit 0 - npm install npm run jsdoc ;; "realmjs") @@ -378,18 +369,8 @@ case "$TARGET" in ;; "test-runners") # Create a fake realm module that points to the source root so that test-runner tests can require('realm') - rm -rf "$SRCROOT/tests/test-runners/node_modules/realm" - mkdir -p "$SRCROOT/tests/test-runners/node_modules" - ln -s "../../.." "$SRCROOT/tests/test-runners/node_modules/realm" - npm install --build-from-source - - for runner in ava mocha jest; do - pushd "$SRCROOT/tests/test-runners/$runner" - npm install - npm test - popd - done + npm run test-runners ;; "object-store") pushd src/object-store diff --git a/tests/test-runners/ava/package.json b/tests/test-runners/ava/package.json index c4099996..90e30357 100644 --- a/tests/test-runners/ava/package.json +++ b/tests/test-runners/ava/package.json @@ -3,6 +3,7 @@ "test": "ava" }, "devDependencies": { - "ava": "^0.16.0" + "ava": "^0.16.0", + "realm": "../../.." } } diff --git a/tests/test-runners/jest/package.json b/tests/test-runners/jest/package.json index 42391167..c0caa7f4 100644 --- a/tests/test-runners/jest/package.json +++ b/tests/test-runners/jest/package.json @@ -3,7 +3,8 @@ "test": "jest" }, "devDependencies": { - "jest-cli": "^13.2.3" + "jest-cli": "^13.2.3", + "realm": "../../.." }, "jest": { "testEnvironment": "node", diff --git a/tests/test-runners/mocha/package.json b/tests/test-runners/mocha/package.json index 9c84aa0f..9342e424 100644 --- a/tests/test-runners/mocha/package.json +++ b/tests/test-runners/mocha/package.json @@ -3,6 +3,7 @@ "test": "mocha" }, "devDependencies": { - "mocha": "^3.0.2" + "mocha": "^3.0.2", + "realm": "../../.." } }