Support dynamically reloading custom file .csscomb.json file changes
Instead of using require which caches the result, check if file exists and then use it if it does, otherwise fall back to bundled config.
This commit is contained in:
parent
72db1efa83
commit
fa24f5db23
|
@ -1,5 +1,6 @@
|
||||||
"use strict"
|
"use strict"
|
||||||
Beautifier = require('./beautifier')
|
Beautifier = require('./beautifier')
|
||||||
|
fs = require('fs')
|
||||||
|
|
||||||
module.exports = class JSBeautify extends Beautifier
|
module.exports = class JSBeautify extends Beautifier
|
||||||
name: "CSScomb"
|
name: "CSScomb"
|
||||||
|
@ -23,7 +24,12 @@ module.exports = class JSBeautify extends Beautifier
|
||||||
try
|
try
|
||||||
# Load from Project's .csscomb.json
|
# Load from Project's .csscomb.json
|
||||||
projectConfigPath = atom.project.getDirectories()?[0]?.resolve('.csscomb.json')
|
projectConfigPath = atom.project.getDirectories()?[0]?.resolve('.csscomb.json')
|
||||||
config = require(projectConfigPath) # Will throw error if does not exist
|
#config = require(projectConfigPath) # Will throw error if does not exist
|
||||||
|
|
||||||
|
stats = fs.statSync(projectConfigPath)
|
||||||
|
|
||||||
|
config = Comb.getCustomConfig(projectConfigPath)
|
||||||
|
|
||||||
catch e
|
catch e
|
||||||
# Fallback to csscomb
|
# Fallback to csscomb
|
||||||
config = Comb.getConfig('csscomb')
|
config = Comb.getConfig('csscomb')
|
||||||
|
|
Loading…
Reference in New Issue