|
| 1 | +var fs = require('fs'); |
| 2 | +var path = require('path'); |
| 3 | + |
| 4 | +/** |
| 5 | + * You can provide comments in `.npmscriptrc.js` |
| 6 | + */ |
| 7 | +var config = |
| 8 | +{ |
| 9 | + "build": |
| 10 | + { |
| 11 | + "babel": { "source": "src", "destination": "dist" } |
| 12 | + }, |
| 13 | + |
| 14 | + "publish": |
| 15 | + { |
| 16 | + "prepublish": { "scripts": ["npm run eslint", "npm run test", "npm run build"] } |
| 17 | + }, |
| 18 | + |
| 19 | + "test": |
| 20 | + { |
| 21 | + // Provides a `coverage` handling command that is appended when running on Travis CI. |
| 22 | + "travis": |
| 23 | + { |
| 24 | + "istanbul": { "command": "cover", "options": ["--report lcovonly"] }, |
| 25 | + "report": "./node_modules/.bin/codecov" |
| 26 | + }, |
| 27 | + |
| 28 | + "istanbul": { "command": "cover", "options": ["--include-all-sources --root src -x '**/template/**'"] }, |
| 29 | + "mocha": { "source": "./node_modules/tjsdoc-tests-ecmascript/test/src", "options": ["--require tjsdoc-tests-ecmascript", "--compilers js:babel-register", "-t 120000 --recursive"] } |
| 30 | + }, |
| 31 | + |
| 32 | + // For local developer testing. |
| 33 | + "dev_test": |
| 34 | + { |
| 35 | + "istanbul": { "command": "cover", "options": ["--include-all-sources --root src -x '**/template/**'"] }, |
| 36 | + "mocha": { "source": "./node_modules/tjsdoc-tests-ecmascript/test/src", "options": ["--require tjsdoc-tests-ecmascript", "--compilers js:babel-register", "-t 120000 --recursive"] } |
| 37 | + }, |
| 38 | + |
| 39 | + // Always tests with NPM module: tjsdoc-tests-ecmascript |
| 40 | + "dev_test_npm": |
| 41 | + { |
| 42 | + "mocha": { "source": "./node_modules/tjsdoc-tests-ecmascript/test/src", "options": ["--require tjsdoc-tests-ecmascript", "--compilers js:babel-register", "-t 120000 --recursive"] } |
| 43 | + } |
| 44 | +}; |
| 45 | + |
| 46 | +// Detect if running in development mode and if so attempt to locate local checked out tests. If found use the local |
| 47 | +// tests instead of the NPM module version automatically. |
| 48 | +if (process.env.BABEL_ENV === 'tjsdoc-dev') |
| 49 | +{ |
| 50 | + try |
| 51 | + { |
| 52 | + var testPath = path.resolve('../tjsdoc-tests-ecmascript/package.json'); |
| 53 | + |
| 54 | + if (fs.existsSync(testPath)) |
| 55 | + { |
| 56 | + var testPackage = require(testPath); |
| 57 | + |
| 58 | + if (testPackage.name === 'tjsdoc-tests-ecmascript') |
| 59 | + { |
| 60 | + // Set to local tests. |
| 61 | + config.dev_test.mocha = |
| 62 | + { |
| 63 | + "source": "../tjsdoc-tests-ecmascript/test/src", |
| 64 | + "options": ["--compilers js:babel-register", "-t 120000 --recursive"] |
| 65 | + }; |
| 66 | + } |
| 67 | + } |
| 68 | + } |
| 69 | + catch (err) { /* nop */ } |
| 70 | +} |
| 71 | + |
| 72 | +// Out put a message indicating which testing environment is being used of developer tests are run. |
| 73 | +try |
| 74 | +{ |
| 75 | + var npmArgv = JSON.parse(process.env['npm_config_argv']).cooked; |
| 76 | + var npmScript = npmArgv[1]; |
| 77 | + |
| 78 | + if (npmScript === 'dev-test' || npmScript === 'dev-test-coverage') |
| 79 | + { |
| 80 | + console.log('test location: ' + config.dev_test.mocha.source) |
| 81 | + } |
| 82 | +} |
| 83 | +catch (err) { /* nop */ } |
| 84 | + |
| 85 | +module.exports = config; |
0 commit comments