git ssb

0+

cel-desktop / ssb-pkg



Tree: 65191f9a9664f013ebe726bb95a1a54b086e1bd5

Files: 65191f9a9664f013ebe726bb95a1a54b086e1bd5 / test / test-50-require-with-config / main.js

2070 bytesRaw
1#!/usr/bin/env node
2
3'use strict';
4
5const fs = require('fs');
6const path = require('path');
7const assert = require('assert');
8const utils = require('../utils.js');
9
10assert(!module.parent);
11assert(__dirname === process.cwd());
12
13const target = process.argv[2] || 'host';
14const output = './run-time/test-output.exe';
15const output3 = './run-time-3/dummy';
16
17let left, right, right3;
18utils.mkdirp.sync(path.dirname(output));
19utils.mkdirp.sync(path.dirname(output3));
20
21left = utils.spawn.sync(
22 'node', [ 'test-x-index.js' ]
23);
24
25fs.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
52utils.pkg.sync([
53 '--target', target,
54 '--output', output, '.'
55]);
56
57right = utils.spawn.sync(
58 './' + path.basename(output), [],
59 { cwd: path.dirname(output) }
60);
61
62right3 = utils.spawn.sync(
63 './' + path.join('..', path.dirname(output), path.basename(output)), [],
64 { cwd: path.dirname(output3) }
65);
66
67right = 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
78right3 = 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
89if (left.length === 0) {
90 left = 'left is empty';
91}
92
93if (right.length === 0) {
94 right = 'right is empty';
95}
96
97if (right3.length === 0) {
98 right3 = 'right3 is empty';
99}
100
101assert.equal(left, right);
102assert.equal(left, right3);
103utils.vacuum.sync(path.dirname(output));
104utils.vacuum.sync(path.dirname(output3));
105

Built with git-ssb-web