Files: 4c58f1c6c3ddb86a97f27f0c84681d201ef1f75f / test / test-50-path-as-buffer / main.js
1454 bytesRaw
1 | |
2 | |
3 | /* eslint-disable no-multi-spaces */ |
4 | |
5 | 'use strict'; |
6 | |
7 | const path = require('path'); |
8 | const assert = require('assert'); |
9 | const utils = require('../utils.js'); |
10 | |
11 | assert(!module.parent); |
12 | assert(__dirname === process.cwd()); |
13 | |
14 | const host = 'node' + process.version.match(/^v(\d+)/)[1]; |
15 | const target = process.argv[2] || host; |
16 | const input = './test-x-index.js'; |
17 | const output = './test-output.exe'; |
18 | |
19 | function bitty (version) { |
20 | return (2 * (/^(node|v)?4/.test(version))) | |
21 | (2 * (/^(node|v)?5/.test(version))) | |
22 | (2 * (/^(node|v)?6/.test(version))) | |
23 | (2 * (/^(node|v)?7/.test(version))) | |
24 | (2 * (/^(node|v)?8/.test(version))) | // 2 = doesn't have URL |
25 | (4 * (/^(node|v)?9/.test(version))) | |
26 | (4 * (/^(node|v)?10/.test(version))) | |
27 | (4 * (/^(node|v)?11/.test(version))) | |
28 | (4 * (/^(node|v)?12/.test(version))) | |
29 | (4 * (/^(node|v)?13/.test(version))) | |
30 | (4 * (/^(node|v)?14/.test(version))); // 4 = has URL |
31 | } |
32 | |
33 | const version1 = process.version; |
34 | const version2 = target; |
35 | if (bitty(version1) !== bitty(version2)) return; |
36 | |
37 | let left, right; |
38 | |
39 | left = utils.spawn.sync( |
40 | 'node', [ path.basename(input) ], |
41 | { cwd: path.dirname(input) } |
42 | ); |
43 | |
44 | utils.pkg.sync([ |
45 | '--target', target, |
46 | '--output', output, input |
47 | ]); |
48 | |
49 | right = utils.spawn.sync( |
50 | './' + path.basename(output), [], |
51 | { cwd: path.dirname(output) } |
52 | ); |
53 | |
54 | assert.equal(left, right); |
55 | utils.vacuum.sync(output); |
56 |
Built with git-ssb-web