fix calling hardhat compile in win32

pull/5370/head
yann300 2 years ago
parent 72e760a6d4
commit 1ec222fd07
  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' const errMsg = '[Hardhat Compilation]: Cannot compile in read-only mode'
return reject(new Error(errMsg)) 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 options = { cwd: this.currentSharedFolder, shell: true }
const child = spawn(cmd, options) const child = spawn(cmd, options)
let result = '' let result = ''

@ -44,10 +44,10 @@ function relativePath (path: string, sharedFolder: string): string {
return normalizePath(relative) return normalizePath(relative)
} }
function normalizePath (path: string): string { function normalizePath (path) {
if (path === '/') path = './' if (path === '/') path = './'
if (process.platform === 'win32') { if (process.platform === 'win32') {
return path.replace(/\\/g, '/') return path.replace(/\//g, '\\')
} }
return path return path
} }
@ -114,4 +114,4 @@ function getDomain (url: string) {
return domainMatch ? domainMatch[0] : null return domainMatch ? domainMatch[0] : null
} }
export { absolutePath, relativePath, walkSync, resolveDirectory, getDomain } export { absolutePath, relativePath, walkSync, resolveDirectory, getDomain, normalizePath }

Loading…
Cancel
Save