Files: ca90b5ca0579ebdcc0635288bce4978e3fb200f5 / test / test-50-native-addon / main.js
907 bytesRaw
1 | |
2 | |
3 | 'use strict'; |
4 | |
5 | const fs = require('fs'); |
6 | const path = require('path'); |
7 | const assert = require('assert'); |
8 | const utils = require('../utils.js'); |
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 | const input = './test-x-index.js'; |
16 | const output = './run-time/test-output.exe'; |
17 | |
18 | let left, right; |
19 | utils.mkdirp.sync(path.dirname(output)); |
20 | |
21 | fs.writeFileSync( |
22 | path.join(path.dirname(output), 'time.node'), |
23 | fs.readFileSync('./lib/time.node') |
24 | ); |
25 | |
26 | left = utils.spawn.sync( |
27 | 'node', [ path.basename(input) ], |
28 | { cwd: path.dirname(input) } |
29 | ); |
30 | |
31 | utils.pkg.sync([ |
32 | '--target', target, |
33 | '--output', output, input |
34 | ]); |
35 | |
36 | right = utils.spawn.sync( |
37 | './' + path.basename(output), [], |
38 | { cwd: path.dirname(output) } |
39 | ); |
40 | |
41 | assert.equal(left, right); |
42 | utils.vacuum.sync(path.dirname(output)); |
43 |
Built with git-ssb-web