node-pty 1.1.0-beta17 → 1.1.0-beta18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/win/conpty.cc +12 -8
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "author": {
5
5
  "name": "Microsoft Corporation"
6
6
  },
7
- "version": "1.1.0-beta17",
7
+ "version": "1.1.0-beta18",
8
8
  "license": "MIT",
9
9
  "main": "./lib/index.js",
10
10
  "types": "./typings/node-pty.d.ts",
package/src/win/conpty.cc CHANGED
@@ -171,20 +171,24 @@ HANDLE LoadConptyDll(const Napi::CallbackInfo& info,
171
171
  return LoadLibraryExW(L"kernel32.dll", 0, 0);
172
172
  }
173
173
  wchar_t currentDir[MAX_PATH];
174
- DWORD result = GetCurrentDirectoryW(MAX_PATH, currentDir);
174
+ HMODULE hModule = GetModuleHandleA("conpty.node");
175
+ if (hModule == NULL) {
176
+ throw errorWithCode(info, "Failed to get conpty.node module handle");
177
+ }
178
+ DWORD result = GetModuleFileNameW(hModule, currentDir, MAX_PATH);
175
179
  if (result == 0) {
176
- throw errorWithCode(info, "Failed to get current directory");
180
+ throw errorWithCode(info, "Failed to get conpty.node module file name");
177
181
  }
178
- std::wstring currentDirStr(currentDir);
179
-
180
- std::wstring conptyDllPath = currentDirStr + L"\\build\\Release\\conpty\\conpty.dll";
182
+ PathRemoveFileSpecW(currentDir);
183
+ wchar_t conptyDllPath[MAX_PATH];
184
+ PathCombineW(conptyDllPath, currentDir, L"conpty\\conpty.dll");
181
185
  if (!path_util::file_exists(conptyDllPath)) {
182
- std::wstring errorMessage = L"Cannot find conpty.dll at " + conptyDllPath;
183
- std::string errorMessageStr(errorMessage.begin(), errorMessage.end());
186
+ std::wstring errorMessage = L"Cannot find conpty.dll at " + std::wstring(conptyDllPath);
187
+ std::string errorMessageStr = path_util::wstring_to_string(errorMessage);
184
188
  throw errorWithCode(info, errorMessageStr.c_str());
185
189
  }
186
190
 
187
- return LoadLibraryW(conptyDllPath.c_str());
191
+ return LoadLibraryW(conptyDllPath);
188
192
  }
189
193
 
190
194
  HRESULT CreateNamedPipesAndPseudoConsole(const Napi::CallbackInfo& info,