зеркало из https://github.com/electron/electron.git
fix: don't use deprecated fstatNoException API (#14463)
This commit is contained in:
Родитель
35a1849e31
Коммит
c5820bfabb
|
@ -19,13 +19,15 @@ const getExtensionMetadata = (extensionId) => {
|
|||
|
||||
const getMessagesPath = (extensionId, language) => {
|
||||
const metadata = getExtensionMetadata(extensionId)
|
||||
const defaultLocale = metadata.default_locale || 'en'
|
||||
const localesDirectory = path.join(metadata.srcDirectory, '_locales')
|
||||
let messagesPath = path.join(localesDirectory, language, 'messages.json')
|
||||
if (!fs.statSyncNoException(messagesPath)) {
|
||||
messagesPath = path.join(localesDirectory, defaultLocale, 'messages.json')
|
||||
try {
|
||||
const filename = path.join(localesDirectory, language, 'messages.json')
|
||||
fs.accessSync(filename, fs.constants.R_OK)
|
||||
return filename
|
||||
} catch (err) {
|
||||
const defaultLocale = metadata.default_locale || 'en'
|
||||
return path.join(localesDirectory, defaultLocale, 'messages.json')
|
||||
}
|
||||
return messagesPath
|
||||
}
|
||||
|
||||
const getMessages = (extensionId, language) => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче