fix: resolve local-registry config

This commit is contained in:
zkochan
2017-02-26 21:20:17 +02:00
parent be633ffb73
commit 15402c4803
2 changed files with 12 additions and 3 deletions

View File

@@ -35,5 +35,8 @@ export default (opts?: PnpmOptions): StrictPnpmOptions => {
if (extendedOpts.force) {
logger.warn('using --force I sure hope you know what you are doing')
}
if (extendedOpts.localRegistry !== DEFAULT_LOCAL_REGISTRY) {
extendedOpts.localRegistry = expandTilde(extendedOpts.localRegistry, extendedOpts.cwd)
}
return extendedOpts
}

View File

@@ -1,13 +1,19 @@
import osHomedir = require('os-homedir')
import path = require('path')
export default function expandTilde (filepath: string) {
export default function expandTilde (filepath: string, cwd?: string) {
const home = getHomedir()
if (!isHomepath(filepath)) {
if (isHomepath(filepath)) {
return path.join(home, filepath.substr(2))
}
if (path.isAbsolute(filepath)) {
return filepath
}
return path.resolve(home, filepath.substr(2))
if (cwd) {
return path.join(cwd, filepath)
}
return path.resolve(filepath)
}
function getHomedir () {