This PR fixes an issue that happens, at least on Windows, when the user has a space character in their Username.
The symptom:
> ssc init
node:internal/modules/cjs/loader:1147
throw err;
^
Error: Cannot find module 'C:\Users\Jan%20Starzak\AppData\Roaming\nvm\v20.11.1\node_modules\@socketsupply\socket\node_modules\@socketsupply\socket-win32-x64\bin\ssc-platform.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
at Module._load (node:internal/modules/cjs/loader:985:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
at node:internal/main/run_main_module:28:49 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
On Windows (but maybe on other platforms too), file URLs can contain spaces which will be encoded as %20. When treating these URL strings as paths, the OS will claim it doesn't recognize these paths because it won't URL-decode them automatically.
The ENOENT here is caused by the un-url'ed cwd property passed into spawn.
Therefore, the import.meta.url needs to be converted to an actual filePath before all the other path processing can be done to it.
This PR fixes an issue that happens, at least on Windows, when the user has a space character in their Username.
The symptom:
On Windows (but maybe on other platforms too), file URLs can contain spaces which will be encoded as %20. When treating these URL strings as paths, the OS will claim it doesn't recognize these paths because it won't URL-decode them automatically. The ENOENT here is caused by the un-url'ed
cwd
property passed intospawn
. Therefore, theimport.meta.url
needs to be converted to an actual filePath before all the other path processing can be done to it.