refactor: make CHROME_GET_MESSAGES handler async (#17148)
This commit is contained in:
parent
bfa07ec4be
commit
64078324bf
1 changed files with 5 additions and 5 deletions
|
@ -12,6 +12,9 @@ const path = require('path')
|
|||
const url = require('url')
|
||||
const util = require('util')
|
||||
|
||||
const readFile = util.promisify(fs.readFile)
|
||||
const writeFile = util.promisify(fs.writeFile)
|
||||
|
||||
// Mapping between extensionId(hostname) and manifest.
|
||||
const manifestMap = {} // extensionId => manifest
|
||||
const manifestNameMap = {} // name => manifest
|
||||
|
@ -232,9 +235,9 @@ const getMessagesPath = (extensionId) => {
|
|||
}
|
||||
}
|
||||
|
||||
ipcMainUtils.handle('CHROME_GET_MESSAGES', function (event, extensionId) {
|
||||
ipcMainUtils.handle('CHROME_GET_MESSAGES', async function (event, extensionId) {
|
||||
const messagesPath = getMessagesPath(extensionId)
|
||||
return fs.readFileSync(messagesPath)
|
||||
return readFile(messagesPath)
|
||||
})
|
||||
|
||||
const validStorageTypes = new Set(['sync', 'local'])
|
||||
|
@ -267,9 +270,6 @@ const mkdirp = util.promisify((dir, callback) => {
|
|||
})
|
||||
})
|
||||
|
||||
const readFile = util.promisify(fs.readFile)
|
||||
const writeFile = util.promisify(fs.writeFile)
|
||||
|
||||
ipcMainUtils.handle('CHROME_STORAGE_READ', async function (event, storageType, extensionId) {
|
||||
const filePath = getChromeStoragePath(storageType, extensionId)
|
||||
|
||||
|
|
Loading…
Reference in a new issue