Files: 938b7ea4cfaa3cef6e1690b9ef3ea8bd7a0d2de1 / test / test-50-bakery-fetch / main.js
825 bytesRaw
1 | |
2 | |
3 | 'use strict'; |
4 | |
5 | const path = require('path'); |
6 | const assert = require('assert'); |
7 | const utils = require('../utils.js'); |
8 | const fetch = require('pkg-fetch'); |
9 | |
10 | assert(!module.parent); |
11 | assert(__dirname === process.cwd()); |
12 | |
13 | const host = 'node' + process.version.match(/^v(\d+)/)[1]; |
14 | const target = process.argv[2] || host; |
15 | |
16 | let right; |
17 | |
18 | fetch.need({ |
19 | nodeRange: target, |
20 | platform: fetch.system.hostPlatform, |
21 | arch: fetch.system.hostArch |
22 | }).then(function (needed) { |
23 | right = utils.spawn.sync( |
24 | './' + path.basename(needed), |
25 | [ '--expose-gc', |
26 | '-e', 'if (global.gc) console.log("ok");' ], |
27 | { cwd: path.dirname(needed), |
28 | env: { PKG_EXECPATH: 'PKG_INVOKE_NODEJS' } } |
29 | ); |
30 | |
31 | assert.equal(right, 'ok\n'); |
32 | }).catch(function (error) { |
33 | console.error(`> ${error.message}`); |
34 | process.exit(2); |
35 | }); |
36 |
Built with git-ssb-web