mirror of https://github.com/lukechilds/node.git
Browse Source
The `path.resolve()` function when given just a drive letter such as "C:" tries to get a drive-specific CWD, but that isn't available in cases when the process is not launched via cmd.exe and the process CWD has not been explicitly set on that drive. This change adds a fallback to the process CWD, if the process CWD happens to be on the resolved drive letter. If the process CWD is on another drive, then a drive-specific CWD cannot be resolved and defaults to the drive's root as before. Based on experimentation, the fixed behavior matches that of other similar path resolution implementations on Windows I checked: .NET's `System.IO.Path.GetFullPath()` and Python's `os.path.abspath()`. In the automated path test cases the issue doesn't occur when the tests are run normally from cmd.exe. But it did cause an assertion when running the tests from PowerShell, that is fixed by this change. PR-URL: https://github.com/nodejs/node/pull/8541 Fixes: https://github.com/nodejs/node/issues/7215 Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com> Reviewed-By: James M Snell <jasnell@gmail.com>v6
Jason Ginchereau
8 years ago
committed by
Ilkka Myller
3 changed files with 21 additions and 3 deletions
@ -0,0 +1,4 @@ |
|||
// Tests resolving a path in the context of a spawned process.
|
|||
// See https://github.com/nodejs/node/issues/7215
|
|||
var path = require('path'); |
|||
console.log(path.resolve(process.argv[2])); |
Loading…
Reference in new issue