Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make 'rc.path' absolute #158

Merged
merged 3 commits into from
Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 4 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,8 @@ 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.path, path.resolve(tmp, rc.p), 'path alias')
vweevers marked this conversation as resolved.
Show resolved Hide resolved
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 +146,7 @@ function runRc (t, args, env, cb) {
return t.fail(e)
}

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