fix crash when hosts not exist

This commit is contained in:
HolographicHat
2022-04-01 20:31:49 +08:00
parent 5fe6e80cc8
commit ab47ff2b06
2 changed files with 5 additions and 2 deletions

View File

@@ -228,6 +228,9 @@ let hostsContent = ""
const setupHost = (restore = false) => {
const path = "C:\\Windows\\System32\\drivers\\etc\\hosts"
if (!fs.existsSync(path)) {
fs.writeFileSync(path, "")
}
fs.chmodSync(path, 0o777)
if (restore) {
fs.writeFileSync(path, hostsContent)