Files: 67c0e15a98a66eb99db2251478505d6f3d37535c / test / test.js
1870 bytesRaw
1 | |
2 | |
3 | 'use strict'; |
4 | |
5 | const chalk = require('chalk'); |
6 | const globby = require('globby'); |
7 | const path = require('path'); |
8 | const utils = require('./utils.js'); |
9 | const host = 'node' + process.version.match(/^v(\d+)/)[1]; |
10 | let target = process.argv[2] || 'host'; |
11 | if (target === 'host') target = host; |
12 | const flavor = process.argv[3] || 'all'; |
13 | |
14 | console.log(''); |
15 | console.log('*************************************'); |
16 | console.log(target + ' ' + flavor); |
17 | console.log('*************************************'); |
18 | console.log(''); |
19 | |
20 | if (process.env.CI) { |
21 | if (target === 'node0' || |
22 | target === 'node4' || |
23 | target === 'node6' || |
24 | target === 'node7' || |
25 | target === 'node9' || |
26 | target === 'node11' || |
27 | target === 'node13') { |
28 | console.log(target + ' is skipped in CI!'); |
29 | console.log(''); |
30 | process.exit(); |
31 | } |
32 | } |
33 | |
34 | function joinAndForward (d) { |
35 | let r = path.join(__dirname, d); |
36 | if (process.platform === 'win32') r = r.replace(/\\/g, '/'); |
37 | return r; |
38 | } |
39 | |
40 | const list = []; |
41 | |
42 | if (flavor === 'only-npm') { |
43 | list.push(joinAndForward('test-79-npm/main.js')); |
44 | } else { |
45 | list.push(joinAndForward('**/main.js')); |
46 | if (flavor === 'no-npm') { |
47 | list.push('!' + joinAndForward('test-42-fetch-all')); |
48 | list.push('!' + joinAndForward('test-46-multi-arch')); |
49 | list.push('!' + joinAndForward('test-46-multi-arch-2')); |
50 | list.push('!' + joinAndForward('test-79-npm')); |
51 | } |
52 | } |
53 | |
54 | const files = globby.sync(list); |
55 | |
56 | files.sort().some(function (file) { |
57 | file = path.resolve(file); |
58 | try { |
59 | utils.spawn.sync( |
60 | 'node', [ path.basename(file), target ], |
61 | { cwd: path.dirname(file), stdio: 'inherit' } |
62 | ); |
63 | } catch (error) { |
64 | console.log(); |
65 | console.log(`> ${chalk.red('Error!')} ${error.message}`); |
66 | console.log(`> ${chalk.red('Error!')} ${file} FAILED (in ${target})`); |
67 | process.exit(2); |
68 | } |
69 | console.log(file, 'ok'); |
70 | }); |
71 |
Built with git-ssb-web