fix calling hardhat compile in win32

pull/3524/head
yann300 2 years ago
parent 72b54ff07e
commit 2791a4cf08
  1. 2
      libs/remixd/src/services/hardhatClient.ts
  2. 6
      libs/remixd/src/utils.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 = ''

@ -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 }

Loading…
Cancel
Save