From 2791a4cf086589f47ecad26cf857d7dc1e0f5594 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 14 Mar 2023 15:33:44 +0100 Subject: [PATCH 1/2] fix calling hardhat compile in win32 --- libs/remixd/src/services/hardhatClient.ts | 2 +- libs/remixd/src/utils.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/remixd/src/services/hardhatClient.ts b/libs/remixd/src/services/hardhatClient.ts index bf7ca0cc9d..63749d3be3 100644 --- a/libs/remixd/src/services/hardhatClient.ts +++ b/libs/remixd/src/services/hardhatClient.ts @@ -54,7 +54,7 @@ export class HardhatClient extends PluginClient { const errMsg = '[Hardhat Compilation]: Cannot compile in read-only mode' return reject(new Error(errMsg)) } - const cmd = `npx hardhat compile --config ${configPath}` + const cmd = utils.normalizePath(`./node_modules/.bin/hardhat compile --config ${utils.normalizePath(configPath)}`) const options = { cwd: this.currentSharedFolder, shell: true } const child = spawn(cmd, options) let result = '' diff --git a/libs/remixd/src/utils.ts b/libs/remixd/src/utils.ts index 067e5f4113..9c0963e296 100644 --- a/libs/remixd/src/utils.ts +++ b/libs/remixd/src/utils.ts @@ -44,10 +44,10 @@ function relativePath (path: string, sharedFolder: string): string { return normalizePath(relative) } -function normalizePath (path: string): string { +function normalizePath (path) { if (path === '/') path = './' if (process.platform === 'win32') { - return path.replace(/\\/g, '/') + return path.replace(/\//g, '\\') } return path } @@ -114,4 +114,4 @@ function getDomain (url: string) { return domainMatch ? domainMatch[0] : null } -export { absolutePath, relativePath, walkSync, resolveDirectory, getDomain } +export { absolutePath, relativePath, walkSync, resolveDirectory, getDomain, normalizePath } From 15ca5b9c0103f337641f3dd50354c8be01154b29 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 15 Mar 2023 09:11:20 +0100 Subject: [PATCH 2/2] rollback use of npx --- libs/remixd/src/services/hardhatClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remixd/src/services/hardhatClient.ts b/libs/remixd/src/services/hardhatClient.ts index 63749d3be3..3928e9af64 100644 --- a/libs/remixd/src/services/hardhatClient.ts +++ b/libs/remixd/src/services/hardhatClient.ts @@ -54,7 +54,7 @@ export class HardhatClient extends PluginClient { const errMsg = '[Hardhat Compilation]: Cannot compile in read-only mode' return reject(new Error(errMsg)) } - const cmd = utils.normalizePath(`./node_modules/.bin/hardhat compile --config ${utils.normalizePath(configPath)}`) + const cmd = `npx hardhat compile --config ${utils.normalizePath(configPath)}` const options = { cwd: this.currentSharedFolder, shell: true } const child = spawn(cmd, options) let result = ''