Skip to content

Commit 57bcc06

Browse files
authoredAug 11, 2021
Make 'rc.path' absolute (#158)
Closes #157.
1 parent cca87fb commit 57bcc06

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed
 

‎rc.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
var path = require('path')
12
var minimist = require('minimist')
23
var getAbi = require('node-abi').getAbi
34
var detectLibc = require('detect-libc')
@@ -42,9 +43,7 @@ module.exports = function (pkg) {
4243
}
4344
}))
4445

45-
if (rc.path === true) {
46-
delete rc.path
47-
}
46+
rc.path = path.resolve(rc.path === true ? '.' : rc.path || '.')
4847

4948
if (napi.isNapiRuntime(rc.runtime) && rc.target === process.versions.node) {
5049
rc.target = napi.getBestNapiBuildVersion()

‎test/rc-test.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ test('custom config and aliases', function (t) {
1919
'--libc testlibc',
2020
'--token TOKEN'
2121
]
22-
runRc(t, args.join(' '), {}, function (rc) {
22+
runRc(t, args.join(' '), {}, function (rc, tmp) {
2323
t.equal(rc.arch, 'ARCH', 'correct arch')
2424
t.equal(rc.arch, rc.a, 'arch alias')
2525
t.equal(rc.platform, 'PLATFORM', 'correct platform')
@@ -30,8 +30,7 @@ test('custom config and aliases', function (t) {
3030
t.equal(rc.version, rc.v, 'version alias')
3131
t.equal(rc.help, true, 'help is set')
3232
t.equal(rc.help, rc.h, 'help alias')
33-
t.equal(rc.path, '../some/other/path', 'correct path')
34-
t.equal(rc.path, rc.p, 'path alias')
33+
t.equal(rc.path, path.resolve(tmp, '../some/other/path'), 'correct path')
3534
t.equal(rc.target, '1.4.10', 'correct target')
3635
t.equal(rc.target, rc.t, 'target alias')
3736
t.equal(rc.runtime, 'electron', 'correct runtime')
@@ -146,7 +145,7 @@ function runRc (t, args, env, cb) {
146145
return t.fail(e)
147146
}
148147

149-
cb(result)
148+
cb(result, tmp)
150149
})
151150
})
152151
}

0 commit comments

Comments
 (0)
Please sign in to comment.