mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
DRY up checking if path is .cson or .json
This commit is contained in:
@@ -9,8 +9,7 @@ module.exports =
|
||||
class TextMateGrammar
|
||||
@readFromPath: (path) ->
|
||||
grammarContent = null
|
||||
extension = fs.extension(path)
|
||||
if extension is '.cson' or extension is '.json'
|
||||
if fs.isObjectPath(path)
|
||||
grammarContent = fs.readObject(path)
|
||||
else
|
||||
plist.parseString fs.read(path), (e, data) ->
|
||||
|
||||
@@ -20,9 +20,7 @@ module.exports =
|
||||
|
||||
continue if fs.base(snippetsPath).indexOf('.') is 0
|
||||
try
|
||||
extension = fs.extension(snippetsPath)
|
||||
objectExtension = extension is '.cson' or extension is '.json'
|
||||
if objectExtension and object = fs.readObject(snippetsPath)
|
||||
if fs.isObjectPath(snippetsPath) and object = fs.readObject(snippetsPath)
|
||||
snippets.push(object)
|
||||
else if object = fs.readPlist(snippetsPath)
|
||||
snippets.push(object)
|
||||
|
||||
@@ -186,6 +186,10 @@ module.exports =
|
||||
base = @base(path, extension).toLowerCase()
|
||||
base is 'readme' and (extension is '' or @isMarkdownExtension(extension))
|
||||
|
||||
isObjectPath: (path) ->
|
||||
extension = @extension(path)
|
||||
extension is '.cson' or extension is '.json'
|
||||
|
||||
readObject: (path) ->
|
||||
contents = @read(path)
|
||||
if @extension(path) is '.cson'
|
||||
|
||||
Reference in New Issue
Block a user