Skip to content

Commit

Permalink
fix calling hardhat compile in win32
Browse files Browse the repository at this point in the history
  • Loading branch information
yann300 committed Mar 15, 2023
1 parent 72b54ff commit 2791a4c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion libs/remixd/src/services/hardhatClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
Expand Down
6 changes: 3 additions & 3 deletions libs/remixd/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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 }

0 comments on commit 2791a4c

Please sign in to comment.