Use the wx flag to atomically create a config file if it doesn't exist

This commit is contained in:
Ash Wilson
2017-09-12 10:19:38 -04:00
parent 8b94ed9558
commit b45fb2e918

View File

@@ -862,11 +862,8 @@ class Config
console.log 'loadUserConfig'
try
# fs.makeTreeSync(path.dirname(@configFilePath))
# CSON.writeFileSync(@configFilePath, {flag: 'x'}, {}) # fails if file exists
unless fs.existsSync(@configFilePath)
fs.makeTreeSync(path.dirname(@configFilePath))
CSON.writeFileSync(@configFilePath, {})
fs.makeTreeSync(path.dirname(@configFilePath))
CSON.writeFileSync(@configFilePath, {}, {flag: 'wx'}) # fails if file exists
catch error
@configFileHasErrors = true
@notifyFailure("Failed to initialize `#{path.basename(@configFilePath)}`", error.stack)