fix(cli): load nodes and credentials on windows using the correct file-path (#4084)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2022-09-12 18:48:50 +02:00 committed by GitHub
parent 3de0e228cb
commit b6c1187922
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -238,6 +238,9 @@ export function isNpmError(error: unknown): error is { code: number; stdout: str
const context = createContext({ require });
export const loadClassInIsolation = (filePath: string, className: string) => {
if (process.platform === 'win32') {
filePath = filePath.replace(/\\/g, '/');
}
const script = new Script(`new (require('${filePath}').${className})()`);
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return script.runInContext(context);