Files: e9d9dec1d00ff365112ca0f981bbda15e3682528 / test / test-50-require-with-config / main.js
2070 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 target = process.argv[2] || 'host'; |
14 | const output = './run-time/test-output.exe'; |
15 | const output3 = './run-time-3/dummy'; |
16 | |
17 | let left, right, right3; |
18 | utils.mkdirp.sync(path.dirname(output)); |
19 | utils.mkdirp.sync(path.dirname(output3)); |
20 | |
21 | left = utils.spawn.sync( |
22 | 'node', [ 'test-x-index.js' ] |
23 | ); |
24 | |
25 | fs.readdirSync('./').some(function (file) { |
26 | if (/^test-/.test(file)) { |
27 | const nf = path.join( |
28 | path.dirname(file), |
29 | path.basename(path.dirname(output)), |
30 | path.basename(file) |
31 | ); |
32 | fs.writeFileSync( |
33 | nf, |
34 | fs.readFileSync(file, 'utf8').replace( |
35 | 'compile-time', 'run-time' |
36 | ) |
37 | ); |
38 | const nf3 = path.join( |
39 | path.dirname(file), |
40 | path.basename(path.dirname(output3)), |
41 | path.basename(file) |
42 | ); |
43 | fs.writeFileSync( |
44 | nf3, |
45 | fs.readFileSync(file, 'utf8').replace( |
46 | 'compile-time', 'run-time-3' |
47 | ) |
48 | ); |
49 | } |
50 | }); |
51 | |
52 | utils.pkg.sync([ |
53 | '--target', target, |
54 | '--output', output, '.' |
55 | ]); |
56 | |
57 | right = utils.spawn.sync( |
58 | './' + path.basename(output), [], |
59 | { cwd: path.dirname(output) } |
60 | ); |
61 | |
62 | right3 = utils.spawn.sync( |
63 | './' + path.join('..', path.dirname(output), path.basename(output)), [], |
64 | { cwd: path.dirname(output3) } |
65 | ); |
66 | |
67 | right = right.replace( |
68 | /-J-run-time/g, |
69 | '-J-compile-time' |
70 | ).replace( |
71 | /-K-run-time/g, |
72 | '-K-compile-time' |
73 | ).replace( |
74 | /-L-run-time/g, |
75 | '-L-compile-time' |
76 | ); |
77 | |
78 | right3 = right3.replace( |
79 | /-J-run-time-3/g, |
80 | '-J-compile-time' |
81 | ).replace( |
82 | /-K-run-time-3/g, |
83 | '-K-compile-time' |
84 | ).replace( |
85 | /-L-run-time-3/g, |
86 | '-L-compile-time' |
87 | ); |
88 | |
89 | if (left.length === 0) { |
90 | left = 'left is empty'; |
91 | } |
92 | |
93 | if (right.length === 0) { |
94 | right = 'right is empty'; |
95 | } |
96 | |
97 | if (right3.length === 0) { |
98 | right3 = 'right3 is empty'; |
99 | } |
100 | |
101 | assert.equal(left, right); |
102 | assert.equal(left, right3); |
103 | utils.vacuum.sync(path.dirname(output)); |
104 | utils.vacuum.sync(path.dirname(output3)); |
105 |
Built with git-ssb-web