Skip to content

Commit 7627b04

Browse files
jasnelltargos
authored andcommitted
test: use module.exports consistently
PR-URL: #22557 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Weijia Wang <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 8930268 commit 7627b04

File tree

2 files changed

+34
-24
lines changed

2 files changed

+34
-24
lines changed

test/common/shared-lib-util.js

+24-20
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,52 @@
22
const common = require('../common');
33
const path = require('path');
44

5+
const kNodeShared = Boolean(process.config.variables.node_shared);
6+
const kShlibSuffix = process.config.variables.shlib_suffix;
7+
const kExecPath = path.dirname(process.execPath);
8+
59
// If node executable is linked to shared lib, need to take care about the
610
// shared lib path.
7-
exports.addLibraryPath = function(env) {
8-
if (!process.config.variables.node_shared) {
11+
function addLibraryPath(env) {
12+
if (!kNodeShared) {
913
return;
1014
}
1115

1216
env = env || process.env;
1317

1418
env.LD_LIBRARY_PATH =
1519
(env.LD_LIBRARY_PATH ? env.LD_LIBRARY_PATH + path.delimiter : '') +
16-
path.join(path.dirname(process.execPath), 'lib.target');
20+
path.join(kExecPath, 'lib.target');
1721
// For AIX.
1822
env.LIBPATH =
1923
(env.LIBPATH ? env.LIBPATH + path.delimiter : '') +
20-
path.join(path.dirname(process.execPath), 'lib.target');
24+
path.join(kExecPath, 'lib.target');
2125
// For Mac OSX.
2226
env.DYLD_LIBRARY_PATH =
2327
(env.DYLD_LIBRARY_PATH ? env.DYLD_LIBRARY_PATH + path.delimiter : '') +
24-
path.dirname(process.execPath);
28+
kExecPath;
2529
// For Windows.
26-
env.PATH =
27-
(env.PATH ? env.PATH + path.delimiter : '') +
28-
path.dirname(process.execPath);
29-
};
30+
env.PATH = (env.PATH ? env.PATH + path.delimiter : '') + kExecPath;
31+
}
3032

3133
// Get the full path of shared lib.
32-
exports.getSharedLibPath = function() {
34+
function getSharedLibPath() {
3335
if (common.isWindows) {
34-
return path.join(path.dirname(process.execPath), 'node.dll');
36+
return path.join(kExecPath, 'node.dll');
3537
} else if (common.isOSX) {
36-
return path.join(path.dirname(process.execPath),
37-
`libnode.${process.config.variables.shlib_suffix}`);
38+
return path.join(kExecPath, `libnode.${kShlibSuffix}`);
3839
} else {
39-
return path.join(path.dirname(process.execPath),
40-
'lib.target',
41-
`libnode.${process.config.variables.shlib_suffix}`);
40+
return path.join(kExecPath, 'lib.target', `libnode.${kShlibSuffix}`);
4241
}
43-
};
42+
}
4443

4544
// Get the binary path of stack frames.
46-
exports.getBinaryPath = function() {
47-
return process.config.variables.node_shared ?
48-
exports.getSharedLibPath() : process.execPath;
45+
function getBinaryPath() {
46+
return kNodeShared ? getSharedLibPath() : process.execPath;
47+
}
48+
49+
module.exports = {
50+
addLibraryPath,
51+
getBinaryPath,
52+
getSharedLibPath
4953
};

test/common/tmpdir.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,15 @@ let tmpdirName = '.tmp';
5959
if (process.env.TEST_THREAD_ID) {
6060
tmpdirName += `.${process.env.TEST_THREAD_ID}`;
6161
}
62-
exports.path = path.join(testRoot, tmpdirName);
6362

64-
exports.refresh = () => {
65-
rimrafSync(exports.path);
66-
fs.mkdirSync(exports.path);
63+
const tmpPath = path.join(testRoot, tmpdirName);
64+
65+
function refresh() {
66+
rimrafSync(this.path);
67+
fs.mkdirSync(this.path);
68+
}
69+
70+
module.exports = {
71+
path: tmpPath,
72+
refresh
6773
};

0 commit comments

Comments
 (0)