Fix #1423 - extname is deprecated
This commit is contained in:
parent
cfe0e6ad8e
commit
86465ff084
|
@ -140,20 +140,32 @@ module.exports = class Beautifiers extends EventEmitter
|
||||||
) or beautifiers[0]
|
) or beautifiers[0]
|
||||||
return beautifier
|
return beautifier
|
||||||
|
|
||||||
getLanguage : (grammar, filePath) ->
|
getExtension : (filePath) ->
|
||||||
|
if filePath
|
||||||
|
return path.extname(filePath).substr(1)
|
||||||
|
|
||||||
|
getLanguages : (grammar, filePath) ->
|
||||||
# Get language
|
# Get language
|
||||||
fileExtension = path.extname(filePath)
|
fileExtension = @getExtension(filePath)
|
||||||
# Remove prefix "." (period) in fileExtension
|
|
||||||
fileExtension = fileExtension.substr(1)
|
if fileExtension
|
||||||
languages = @languages.getLanguages({grammar, extension: fileExtension})
|
languages = @languages.getLanguages({grammar, extension: fileExtension})
|
||||||
logger.verbose(languages, grammar, fileExtension)
|
|
||||||
# Check if unsupported language
|
|
||||||
if languages.length < 1
|
|
||||||
return null
|
|
||||||
else
|
else
|
||||||
# TODO: select appropriate language
|
languages = @languages.getLanguages({grammar})
|
||||||
|
|
||||||
|
logger.verbose(languages, grammar, fileExtension)
|
||||||
|
|
||||||
|
return languages
|
||||||
|
|
||||||
|
getLanguage : (grammar, filePath) ->
|
||||||
|
languages = @getLanguages(grammar, filePath)
|
||||||
|
|
||||||
|
# Check if unsupported language
|
||||||
|
if languages.length > 0
|
||||||
language = languages[0]
|
language = languages[0]
|
||||||
|
|
||||||
|
return language
|
||||||
|
|
||||||
getOptionsForLanguage : (allOptions, language) ->
|
getOptionsForLanguage : (allOptions, language) ->
|
||||||
# Options for Language
|
# Options for Language
|
||||||
selections = (language.fallback or []).concat([language.namespace])
|
selections = (language.fallback or []).concat([language.namespace])
|
||||||
|
@ -241,15 +253,10 @@ module.exports = class Beautifiers extends EventEmitter
|
||||||
logger.info('beautify', text, allOptions, grammar, filePath, onSave)
|
logger.info('beautify', text, allOptions, grammar, filePath, onSave)
|
||||||
logger.verbose(allOptions)
|
logger.verbose(allOptions)
|
||||||
|
|
||||||
# Get language
|
language = @getLanguage(grammar, filePath)
|
||||||
fileExtension = path.extname(filePath)
|
|
||||||
# Remove prefix "." (period) in fileExtension
|
|
||||||
fileExtension = fileExtension.substr(1)
|
|
||||||
languages = @languages.getLanguages({grammar, extension: fileExtension})
|
|
||||||
logger.verbose(languages, grammar, fileExtension)
|
|
||||||
|
|
||||||
# Check if unsupported language
|
# Check if unsupported language
|
||||||
if languages.length < 1
|
if !language
|
||||||
unsupportedGrammar = true
|
unsupportedGrammar = true
|
||||||
|
|
||||||
logger.verbose('Unsupported language')
|
logger.verbose('Unsupported language')
|
||||||
|
@ -260,19 +267,14 @@ module.exports = class Beautifiers extends EventEmitter
|
||||||
# not intended to be beautified
|
# not intended to be beautified
|
||||||
return resolve( null )
|
return resolve( null )
|
||||||
else
|
else
|
||||||
# TODO: select appropriate language
|
|
||||||
language = languages[0]
|
|
||||||
|
|
||||||
logger.verbose("Language #{language.name} supported")
|
logger.verbose("Language #{language.name} supported")
|
||||||
|
|
||||||
# Get language config
|
# Get language config
|
||||||
langDisabled = atom.config.get("atom-beautify.#{language.namespace}.disabled")
|
langDisabled = atom.config.get("atom-beautify.#{language.namespace}.disabled")
|
||||||
|
|
||||||
|
|
||||||
# Beautify!
|
# Beautify!
|
||||||
unsupportedGrammar = false
|
unsupportedGrammar = false
|
||||||
|
|
||||||
|
|
||||||
# Check if Language is disabled
|
# Check if Language is disabled
|
||||||
if langDisabled
|
if langDisabled
|
||||||
logger.verbose("Language #{language.name} is disabled")
|
logger.verbose("Language #{language.name} is disabled")
|
||||||
|
@ -370,6 +372,7 @@ module.exports = class Beautifiers extends EventEmitter
|
||||||
if atom.config.get("atom-beautify.general.muteUnsupportedLanguageErrors")
|
if atom.config.get("atom-beautify.general.muteUnsupportedLanguageErrors")
|
||||||
return resolve( null )
|
return resolve( null )
|
||||||
else
|
else
|
||||||
|
fileExtension = @getExtension(filePath)
|
||||||
repoBugsUrl = pkg.bugs.url
|
repoBugsUrl = pkg.bugs.url
|
||||||
title = "Atom Beautify could not find a supported beautifier for this file"
|
title = "Atom Beautify could not find a supported beautifier for this file"
|
||||||
detail = """
|
detail = """
|
||||||
|
|
Loading…
Reference in New Issue