Skip to content

Commit

Permalink
catch errors and log error path
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidWells committed Feb 12, 2019
1 parent 03a7887 commit 2996b7c
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,13 @@ async function checkCache(d, opts, cacheDirectory) {
const cacheInfo = path.join(cachedContentsDirectory, 'cache.json')
// console.log('cacheInfo', cacheInfo)

const cacheData = await getCacheData(cacheInfo)
let cacheData
try {
cacheData = await getCacheData(cacheInfo)
} catch (e) {
console.log(`cacheData error from ${cacheInfo}`)
console.log(e)
}

let firstRun = false
if (!cacheData) {
Expand All @@ -124,8 +130,15 @@ async function checkCache(d, opts, cacheDirectory) {
})

// shouldCacheUpdate = true
// Get new cache Data. todo refactor
const currentCacheData = await getCacheData(cacheInfo) || {}
let currentCacheData
try {
currentCacheData = await getCacheData(cacheInfo)
} catch (e) {
console.log(`cacheData error from ${cacheInfo}`)
console.log(e)
currentCacheData = {}
}

if (!shouldCacheUpdate && !firstRun) {
console.log(`2. 👍 No changes detected in ${directory}`)

Expand Down Expand Up @@ -232,7 +245,13 @@ async function defaultShouldUpdate(cacheData) {
}

async function diff(filePath, cacheFile) {
const cacheData = await getCacheData(cacheFile) || {}
let cacheData
try {
cacheData = await getCacheData(cacheFile)
} catch (e) {
console.log(`cacheData error from ${cacheFile}`)
cacheData = {}
}
// No change file exists
if (!cacheData.diffs || !Object.keys(cacheData.diffs).length || !cacheData.diffs[filePath]) {
// console.log('previousDiff.diffs', cacheData.diffs)
Expand Down

0 comments on commit 2996b7c

Please sign in to comment.