|
| 1 | +const { spawnSync } = require('child_process'); |
| 2 | +const { join } = require('path'); |
| 3 | + |
| 4 | +function run(cmd: string, cwd: string = '') { |
| 5 | + const result = spawnSync(cmd, { shell: true, stdio: 'inherit', cwd: join(__dirname, '..', cwd) }); |
| 6 | + |
| 7 | + if (result.status !== 0) { |
| 8 | + process.exit(result.status); |
| 9 | + } |
| 10 | +} |
| 11 | + |
| 12 | +const nodeMajorVersion = parseInt(process.version.split('.')[0].replace('v', ''), 10); |
| 13 | + |
| 14 | +// control which packages we test on each version of node |
| 15 | +if (nodeMajorVersion <= 6) { |
| 16 | + // install legacy versions of packages whose current versions don't support node 6 |
| 17 | + // ignoring engines and scripts lets us get away with having incompatible things installed for packages we're not testing |
| 18 | + run('yarn add --dev --ignore-engines --ignore-scripts nock@10.x', 'packages/node'); |
| 19 | + run('yarn add --dev --ignore-engines --ignore-scripts jsdom@11.x', 'packages/tracing'); |
| 20 | + run('yarn add --dev --ignore-engines --ignore-scripts jsdom@11.x', 'packages/utils'); |
| 21 | + |
| 22 | + // only test against @sentry/node and its dependencies - node 6 is too old for anything else to work |
| 23 | + const scope = ['@sentry/core', '@sentry/hub', '@sentry/minimal', '@sentry/node', '@sentry/utils', '@sentry/tracing'] |
| 24 | + .map(dep => `--scope="${dep}"`) |
| 25 | + .join(' '); |
| 26 | + |
| 27 | + run(`yarn test ${scope}`); |
| 28 | +} else if (nodeMajorVersion <= 8) { |
| 29 | + // install legacy versions of packages whose current versions don't support node 8 |
| 30 | + // ignoring engines and scripts lets us get away with having incompatible things installed for packages we're not testing |
| 31 | + run('yarn add --dev --ignore-engines --ignore-scripts jsdom@15.x', 'packages/tracing'); |
| 32 | + run('yarn add --dev --ignore-engines --ignore-scripts jsdom@15.x', 'packages/utils'); |
| 33 | + |
| 34 | + // ember tests happen separately, and the rest fail on node 8 for various syntax or dependency reasons |
| 35 | + const ignore = [ |
| 36 | + '@sentry/ember', |
| 37 | + '@sentry-internal/eslint-plugin-sdk', |
| 38 | + '@sentry/react', |
| 39 | + '@sentry/wasm', |
| 40 | + '@sentry/gatsby', |
| 41 | + '@sentry/serverless', |
| 42 | + '@sentry/nextjs', |
| 43 | + ] |
| 44 | + .map(dep => `--ignore="${dep}"`) |
| 45 | + .join(' '); |
| 46 | + |
| 47 | + run(`yarn test ${ignore}`); |
| 48 | +} else { |
| 49 | + run('yarn test --ignore="@sentry/ember"'); |
| 50 | +} |
| 51 | + |
| 52 | +process.exit(0); |
0 commit comments