Skip to content

Commit

Permalink
Make 'rc.path' absolute (#158)
Browse files Browse the repository at this point in the history
Closes #157.
  • Loading branch information
dunkmann00 authored Aug 11, 2021
1 parent cca87fb commit 57bcc06
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
5 changes: 2 additions & 3 deletions rc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
var path = require('path')
var minimist = require('minimist')
var getAbi = require('node-abi').getAbi
var detectLibc = require('detect-libc')
Expand Down Expand Up @@ -42,9 +43,7 @@ module.exports = function (pkg) {
}
}))

if (rc.path === true) {
delete rc.path
}
rc.path = path.resolve(rc.path === true ? '.' : rc.path || '.')

if (napi.isNapiRuntime(rc.runtime) && rc.target === process.versions.node) {
rc.target = napi.getBestNapiBuildVersion()
Expand Down
7 changes: 3 additions & 4 deletions test/rc-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test('custom config and aliases', function (t) {
'--libc testlibc',
'--token TOKEN'
]
runRc(t, args.join(' '), {}, function (rc) {
runRc(t, args.join(' '), {}, function (rc, tmp) {
t.equal(rc.arch, 'ARCH', 'correct arch')
t.equal(rc.arch, rc.a, 'arch alias')
t.equal(rc.platform, 'PLATFORM', 'correct platform')
Expand All @@ -30,8 +30,7 @@ test('custom config and aliases', function (t) {
t.equal(rc.version, rc.v, 'version alias')
t.equal(rc.help, true, 'help is set')
t.equal(rc.help, rc.h, 'help alias')
t.equal(rc.path, '../some/other/path', 'correct path')
t.equal(rc.path, rc.p, 'path alias')
t.equal(rc.path, path.resolve(tmp, '../some/other/path'), 'correct path')
t.equal(rc.target, '1.4.10', 'correct target')
t.equal(rc.target, rc.t, 'target alias')
t.equal(rc.runtime, 'electron', 'correct runtime')
Expand Down Expand Up @@ -146,7 +145,7 @@ function runRc (t, args, env, cb) {
return t.fail(e)
}

cb(result)
cb(result, tmp)
})
})
}

0 comments on commit 57bcc06

Please sign in to comment.