Commit 85d371ed authored by aniket-engg's avatar aniket-engg Committed by Aniket

check if remixd shared folder exists

parent 30fac041
...@@ -6,7 +6,7 @@ import * as servicesList from '../serviceList' ...@@ -6,7 +6,7 @@ import * as servicesList from '../serviceList'
import * as WS from 'ws' // eslint-disable-line import * as WS from 'ws' // eslint-disable-line
import { getDomain, absolutePath } from '../utils' import { getDomain, absolutePath } from '../utils'
import Axios from 'axios' import Axios from 'axios'
import * as fs from 'fs-extra' import { writeJSON, existsSync } from 'fs-extra'
import * as path from 'path' import * as path from 'path'
import * as program from 'commander' import * as program from 'commander'
...@@ -83,7 +83,7 @@ function errorHandler (error: any, service: string) { ...@@ -83,7 +83,7 @@ function errorHandler (error: any, service: string) {
console.log('\x1b[33m%s\x1b[0m', '[WARN] You may now only use IDE at ' + program.remixIde + ' to connect to that instance') console.log('\x1b[33m%s\x1b[0m', '[WARN] You may now only use IDE at ' + program.remixIde + ' to connect to that instance')
} }
if (program.sharedFolder) { if (program.sharedFolder && existsSync(absolutePath('./', program.sharedFolder))) {
console.log('\x1b[33m%s\x1b[0m', '[WARN] Any application that runs on your computer can potentially read from and write to all files in the directory.') console.log('\x1b[33m%s\x1b[0m', '[WARN] Any application that runs on your computer can potentially read from and write to all files in the directory.')
console.log('\x1b[33m%s\x1b[0m', '[WARN] Symbolic links are not forwarded to Remix IDE\n') console.log('\x1b[33m%s\x1b[0m', '[WARN] Symbolic links are not forwarded to Remix IDE\n')
try { try {
...@@ -102,7 +102,7 @@ function errorHandler (error: any, service: string) { ...@@ -102,7 +102,7 @@ function errorHandler (error: any, service: string) {
}) })
// Run hardhat service if a hardhat project is shared as folder // Run hardhat service if a hardhat project is shared as folder
const hardhatConfigFilePath = absolutePath('./', program.sharedFolder) + '/hardhat.config.js' const hardhatConfigFilePath = absolutePath('./', program.sharedFolder) + '/hardhat.config.js'
const isHardhatProject = fs.existsSync(hardhatConfigFilePath) const isHardhatProject = existsSync(hardhatConfigFilePath)
if (isHardhatProject) { if (isHardhatProject) {
startService('hardhat', (ws: WS, sharedFolderClient: servicesList.Sharedfolder, error: Error) => { startService('hardhat', (ws: WS, sharedFolderClient: servicesList.Sharedfolder, error: Error) => {
if (error) { if (error) {
...@@ -151,7 +151,7 @@ function errorHandler (error: any, service: string) { ...@@ -151,7 +151,7 @@ function errorHandler (error: any, service: string) {
const { data } = await Axios.get(gistUrl) const { data } = await Axios.get(gistUrl)
try { try {
await fs.writeJSON(path.resolve(path.join(__dirname, '..', 'origins.json')), { data }) await writeJSON(path.resolve(path.join(__dirname, '..', 'origins.json')), { data })
} catch (e) { } catch (e) {
console.error(e) console.error(e)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment