Throw errors reading/parsing manifest.json
This commit is contained in:
parent
d1ac5dd29b
commit
f46edd5186
1 changed files with 14 additions and 4 deletions
|
@ -22,12 +22,22 @@ const generateExtensionIdFromName = function (name) {
|
|||
// Create or get manifest object from |srcDirectory|.
|
||||
const getManifestFromPath = function (srcDirectory) {
|
||||
let manifest
|
||||
let manifestContent
|
||||
|
||||
try {
|
||||
manifest = JSON.parse(fs.readFileSync(path.join(srcDirectory, 'manifest.json')))
|
||||
} catch (err) {
|
||||
console.warn(`Attempted to load extension from ${srcDirectory}, but parsing the manifest failed.`)
|
||||
console.warn('Error encountered:', err)
|
||||
manifestContent = fs.readFileSync(path.join(srcDirectory, 'manifest.json'))
|
||||
} catch (readError) {
|
||||
console.warn(`Reading ${path.join(srcDirectory, 'manifest.json')} failed.`)
|
||||
console.warn(readError.stack || readError)
|
||||
throw readError
|
||||
}
|
||||
|
||||
try {
|
||||
manifest = JSON.parse(manifestContent)
|
||||
} catch (parseError) {
|
||||
console.warn(`Parsing ${path.join(srcDirectory, 'manifest.json')} failed.`)
|
||||
console.warn(parseError.stack || parseError)
|
||||
throw parseError
|
||||
}
|
||||
|
||||
if (!manifestNameMap[manifest.name]) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue