Skip to content

Commit

Permalink
fix: check if target file exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Pooya Parsa committed Oct 16, 2017
1 parent f651c62 commit dff37a2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions plugin/npm-module/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,14 @@ module.exports = class MonitorStats {
if (!fs.existsSync(targetDir)) {
// ...make directory if it does not
fs.mkdirSync(targetDir);
data = [];
} else {
}

// CHECK IF TARGET FILE EXISTS...
if (fs.existsSync(target)) {
// ...get existing data if it does
data = JSON.parse(fs.readFileSync(target, { encoding: 'utf8' }));
} else {
data = [];
}

compiler.plugin('done', (stats) => {
Expand Down

0 comments on commit dff37a2

Please sign in to comment.