Skip to content

Commit 2539dfe

Browse files
committed
refactor: simplify error logging in WebpackThemeJsonPlugin by removing chalk dependency and updating log messages
1 parent 0bf1b40 commit 2539dfe

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

‎config/webpack-theme-json-plugin.js‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
const chalk = require('chalk')
21
const path = require('path')
32
const fs = require('fs')
43

5-
const logId = '[' + chalk.blue('WebpackThemeJsonPlugin') + ']'
6-
74
class WebpackThemeJsonPlugin {
85
/**
96
* constructor
@@ -32,7 +29,7 @@ class WebpackThemeJsonPlugin {
3229
/**
3330
* apply
3431
*/
35-
apply() {}
32+
apply() { }
3633

3734
/**
3835
* Generate theme json file
@@ -51,21 +48,21 @@ class WebpackThemeJsonPlugin {
5148
json = JSON.parse(json)
5249
} catch (e) {
5350
// eslint-disable-next-line no-console
54-
console.error(logId, 'Error parsing JSON file:', file.name)
51+
console.error('WebpackThemeJsonPlugin: Error parsing JSON file:', file.name)
5552
}
5653

5754
if (isPlainObject(json)) {
5855
extend(true, themeJson, json)
5956
} else {
6057
// eslint-disable-next-line no-console
61-
console.error(logId, 'JSON file is not a plain object:', file.name)
58+
console.error('WebpackThemeJsonPlugin: JSON file is not a plain object:', file.name)
6259
}
6360
}
6461
})
6562

6663
fs.writeFileSync(this._output, JSON.stringify(themeJson, null, 2))
6764
// eslint-disable-next-line no-console
68-
console.log(logId, 'JSON files successfully generated !')
65+
console.log('WebpackThemeJsonPlugin: JSON files successfully generated !')
6966

7067
return this
7168
}
@@ -116,7 +113,7 @@ class WebpackThemeJsonPlugin {
116113
jsonFile = JSON.parse(jsonFile)
117114
} catch (e) {
118115
// eslint-disable-next-line no-console
119-
console.error(logId, 'Error parsing JSON file:', this._output)
116+
console.error('WebpackThemeJsonPlugin: Error parsing JSON file:', this._output)
120117
return this
121118
}
122119

0 commit comments

Comments
 (0)