Skip to content

Commit

Permalink
Merge pull request webpackmonitor#51 from nuxt-community/target-dir
Browse files Browse the repository at this point in the history
fix: targetDir
  • Loading branch information
roachjc authored Oct 16, 2017
2 parents 3a6e717 + dff37a2 commit 91a6dca
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions plugin/npm-module/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,18 @@ module.exports = class MonitorStats {
});

// CHECK IF TARGET DIRECTORY EXISTS...
if (!fs.existsSync(target)) {
const targetDir = path.dirname(target)
if (!fs.existsSync(targetDir)) {
// ...make directory if it does not
fs.mkdirSync(path.resolve(__dirname, '../..', 'monitor'));
data = [];
} else {
fs.mkdirSync(targetDir);
}

// 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 91a6dca

Please sign in to comment.