uglify-js-minify-css-allfiles 2.0.4 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,78 +5,90 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.1.0] - 2024-08-20
9
+
10
+ ### Changed
11
+
12
+ - Logging Enhancements:
13
+ Structured Log Levels: Implemented a new logging system with defined log levels (e.g., info, warn, error) to improve log readability and management.
14
+ Date-based Log Files: Logs are now stored in files organized by date, making it easier to track and analyze logs over time.
15
+ - Type Generation:
16
+ Introduced a new type generation feature to improve type safety and consistency across the application.
17
+
8
18
  ## [2.0.0] - 2024-08-19
9
19
 
10
20
  ### Added
11
21
 
12
- - New logging system for better error tracking and debugging
13
- - Optional Babel integration for advanced JavaScript transpilation
14
- - Support for ES modules, allowing use of `import` statements in your projects
22
+ - See Breaking Changes
15
23
 
16
24
  ### Changed
17
25
 
18
- - Switched from CommonJS (`require`) to ES modules (`import`) for better compatibility with modern JavaScript
19
- - Improved error handling and reporting, providing clearer messages for troubleshooting
20
- - Enhanced CLI interface with more user-friendly options and feedback
26
+ - Switched from CommonJS (`require`) to ES modules (`import`) for better compatibility with modern JavaScript
27
+ - Improved error handling and reporting, providing clearer messages for troubleshooting
28
+ - Enhanced CLI interface with more user-friendly options and feedback
21
29
 
22
30
  ### Improved
23
31
 
24
- - Significantly faster processing of large directories with many files
25
- - More robust handling of different file types and encodings
26
- - Better preservation of source maps in minified files
32
+ - Significantly faster processing of large directories with many files
33
+ - More robust handling of different file types and encodings
34
+ - Better preservation of source maps in minified files
27
35
 
28
36
  ### Breaking Changes
29
37
 
30
- - Minimum Node.js version requirement increased to v14.0.0
31
- - Configuration file format changed (see migration guide for details)
32
- - Some CLI options have been renamed for clarity (see documentation for new option names)
38
+ - Minimum Node.js version requirement increased to v14.0.0
39
+ - Configuration file format changed (see migration guide for details)
40
+ - Some CLI options have been renamed for clarity (see documentation for new option names)
41
+ - Support for ES modules, allowing use of `import` statements in your projects
42
+ - New logging system for better error tracking and debugging
43
+ - Optional Babel integration for advanced JavaScript transpilation
33
44
 
34
45
  ## [1.3.2] - 2023-05-28
35
46
 
36
47
  ### Added
37
48
 
38
- - New `CHANGELOG.md` file
49
+ - New `CHANGELOG.md` file
39
50
 
40
51
  ### Changed
41
52
 
42
- - When CSS warnings exist, no code is minified (2022-04-13)
43
- - Updated UglifyJS to remove 'console.info, console.warn, console.error' (2021-11-12)
44
- - Updated UglifyJS to work without 'console.log' but keep console.error, info, etc. (2021-03-17)
53
+ - When CSS warnings exist, no code is minified (2022-04-13)
54
+ - Updated UglifyJS to remove 'console.info, console.warn, console.error' (2021-11-12)
55
+ - Updated UglifyJS to work without 'console.log' but keep console.error, info, etc. (2021-03-17)
45
56
 
46
57
  ### Fixed
47
58
 
48
- - Bug fix (v1.1.7): Solved CleanCSS first line delete error (2020-08-21)
49
- - Bug fix (v1.1.3): [Description missing] (2020-08-15)
59
+ - Bug fix (v1.1.7): Solved CleanCSS first line delete error (2020-08-21)
60
+ - Bug fix (v1.1.3): [Description missing] (2020-08-15)
50
61
 
51
62
  ## [1.3.1] - 2020-11-03
52
63
 
53
64
  ### Changed
54
65
 
55
- - Updated UglifyJS to support minification of JavaScript files with ES6 syntax
66
+ - Updated UglifyJS to support minification of JavaScript files with ES6 syntax
56
67
 
57
68
  ## [1.3.0] - 2020-08-26
58
69
 
59
70
  ### Changed
60
71
 
61
- - Moved DevDependencies to Dependencies for production use
72
+ - Moved DevDependencies to Dependencies for production use
62
73
 
63
74
  ## [1.2.0] - 2020-08-21
64
75
 
65
76
  ### Fixed
66
77
 
67
- - Solved CleanCSS commentary issue due to changed CSS options
78
+ - Solved CleanCSS commentary issue due to changed CSS options
68
79
 
69
80
  ### Added
70
81
 
71
- - Support for command line execution with 2 parameters
82
+ - Support for command line execution with 2 parameters
72
83
 
73
84
  ## [1.1.0] - 2020-08-20
74
85
 
75
86
  ### Added
76
87
 
77
- - New `exceptFolder` parameter to exclude specific folders from minification
78
- - Support for using relative paths
88
+ - New `exceptFolder` parameter to exclude specific folders from minification
89
+ - Support for using relative paths
79
90
 
91
+ [2.1.0]: https://github.com/oinochoe/uglify-js-minify-css-allfiles/compare/v2.0.0...v2.1.0
80
92
  [2.0.0]: https://github.com/oinochoe/uglify-js-minify-css-allfiles/compare/v1.3.2...v2.0.0
81
93
  [1.3.2]: https://github.com/oinochoe/uglify-js-minify-css-allfiles/compare/v1.3.1...v1.3.2
82
94
  [1.3.1]: https://github.com/oinochoe/uglify-js-minify-css-allfiles/compare/v1.3.0...v1.3.1
package/README.md CHANGED
@@ -23,12 +23,12 @@ You can easily minify all files in a specific folder, with the option to exclude
23
23
 
24
24
  ## Table of Contents
25
25
 
26
- - [Installation](#installation)
27
- - [Usage](#usage)
28
- - [Parameters](#parameters)
29
- - [BabelOptions](#babeloptions)
30
- - [Changelog](#changelog)
31
- - [License](#license)
26
+ - [Installation](#installation)
27
+ - [Usage](#usage)
28
+ - [Parameters](#parameters)
29
+ - [Options](#options)
30
+ - [Changelog](#changelog)
31
+ - [License](#license)
32
32
 
33
33
  ## Installation
34
34
 
@@ -42,57 +42,100 @@ $ npm i uglify-js-minify-css-allfiles
42
42
 
43
43
  1. Basic usage (no Babel):
44
44
 
45
- ```js
46
- import minifyAll from 'uglify-js-minify-css-allfiles';
45
+ ```js
46
+ import minifyAll from 'uglify-js-minify-css-allfiles';
47
+
48
+ await minifyAll('./src/');
49
+ ```
50
+
51
+ 2. Using options:
52
+
53
+ ```js
54
+ import minifyAll from 'uglify-js-minify-css-allfiles';
55
+
56
+ await minifyAll('./src/', {
57
+ excludeFolder: 'node_modules',
58
+ useBabel: {
59
+ targets: 'chrome 40',
60
+ modules: false,
61
+ useBuiltIns: 'usage',
62
+ corejs: 3,
63
+ },
64
+ useLog: {
65
+ logDir: 'logs',
66
+ retentionDays: 30,
67
+ logLevel: 'info',
68
+ dateFormat: 'YYYY-MM-DD',
69
+ timeZone: 'UTC',
70
+ logToConsole: true,
71
+ logToFile: true,
72
+ },
73
+ });
74
+ ```
75
+
76
+ 3. Using Babel and custom logging options:
77
+
78
+ ```js
79
+ import minifyAll from 'uglify-js-minify-css-allfiles';
80
+
81
+ await minifyAll('./src/', {
82
+ useBabel: { targets: 'chrome 40' },
83
+ useLog: {
84
+ logDir: 'logs',
85
+ retentionDays: 30,
86
+ logLevel: 'info',
87
+ dateFormat: 'YYYY-MM-DD',
88
+ timeZone: 'UTC',
89
+ logToConsole: true,
90
+ logToFile: true,
91
+ },
92
+ });
93
+ ```
47
94
 
48
- await minifyAll('./src/', 'node_modules');
49
- ```
95
+ ## Parameters
50
96
 
51
- 2. Using Babel with default settings:
97
+ The `minifyAll` function accepts the following parameters:
52
98
 
53
- ```js
54
- import minifyAll from 'uglify-js-minify-css-allfiles';
99
+ | Parameter | Type | Default | Description |
100
+ | ------------- | ------ | ------- | -------------------------------------------------------------------------------------------- |
101
+ | `contentPath` | string | - | The path to the directory containing the files to be minified. This is a required parameter. |
102
+ | `options` | object | `{}` | An object containing options for minification, Babel, and logging. |
55
103
 
56
- await minifyAll('./src/', 'node_modules', { useBabel: true });
57
- ```
104
+ ## Options
58
105
 
59
- 3. Using custom Babel presets:
106
+ The `options` object can have the following properties:
60
107
 
61
- ```js
62
- import minifyAll from 'uglify-js-minify-css-allfiles';
108
+ | Property | Type | Default | Description |
109
+ | --------------- | ----------------- | ------- | ------------------------------------------------------------------------------------------ |
110
+ | `excludeFolder` | string | `''` | The name of a folder to exclude from minification. |
111
+ | `useBabel` | boolean \| object | `false` | If `true`, enables Babel with default settings. If an object, specifies Babel options. |
112
+ | `useLog` | boolean \| object | `true` | If `true`, enables logging with default settings. If an object, specifies logging options. |
63
113
 
64
- await minifyAll('./src/', 'node_modules', {
65
- presets: [
66
- [
67
- '@babel/preset-env',
68
- {
69
- targets: {
70
- esmodules: false, // Target ES2015
71
- },
72
- },
73
- ],
74
- ],
75
- });
76
- ```
114
+ ### Babel Options
77
115
 
78
- ## Parameters
79
-
80
- The `minifyAll` function accepts the following parameters:
116
+ When `useBabel` is an object, it can have the following properties:
81
117
 
82
- | Parameter | Type | Default | Description |
83
- | --------------- | -------------- | ------- | -------------------------------------------------------------------------------------------- |
84
- | `contentPath` | string | - | The path to the directory containing the files to be minified. This is a required parameter. |
85
- | `excludeFolder` | string | `''` | The name of a folder to exclude from minification. Leave empty to include all folders. |
86
- | `babelOptions` | object or null | `null` | An object containing Babel options or a flag to use default Babel settings. |
118
+ | Property | Type | Description |
119
+ | ------------------------------------- | --------------------------- | --------------------------------------------------------------------------------------------------------- |
120
+ | `targets` | string \| object | Specifies the target environments. |
121
+ | `modules` | string \| false | Enables transformation of ES6 module syntax to another module type. |
122
+ | `useBuiltIns` | 'usage' \| 'entry' \| false | Configures how babel-preset-env handles polyfills. |
123
+ | `corejs` | number \| object | Specifies the core-js version. |
124
+ | ... (other @babel/preset-env options) | Various | Refer to [@babel/preset-env documentation](https://babeljs.io/docs/en/babel-preset-env) for more options. |
87
125
 
88
- ## BabelOptions
126
+ ### Log Options
89
127
 
90
- The `babelOptions` parameter can have the following properties:
128
+ When `useLog` is an object, it can have the following properties:
91
129
 
92
- | Property | Type | Default | Description |
93
- | ---------- | ------- | ------- | --------------------------------------------------------------------------------------------- |
94
- | `useBabel` | boolean | `false` | If set to `true`, enables Babel transformation with default presets targeting ES2015. |
95
- | `presets` | array | - | Custom Babel presets to use for transformation. If provided, overrides the `useBabel` option. |
130
+ | Property | Type | Default | Description |
131
+ | --------------- | ------- | -------------- | --------------------------------------------------------------------- |
132
+ | `logDir` | string | `'logs'` | Specifies the directory for log files. |
133
+ | `retentionDays` | number | 30 | Number of days to retain log files. |
134
+ | `logLevel` | string | `'info'` | Specifies the level of logging (e.g., `'info'`, `'warn'`, `'error'`). |
135
+ | `dateFormat` | string | `'YYYY-MM-DD'` | Format for the date in log entries. |
136
+ | `timeZone` | string | `'UTC'` | Time zone for timestamps in log entries. |
137
+ | `logToConsole` | boolean | `true` | Determines if logs should also be output to the console. |
138
+ | `logToFile` | boolean | `true` | Determines if logs should be written to a file. |
96
139
 
97
140
  ## Changelog
98
141
 
package/demo.js CHANGED
@@ -1,18 +1,8 @@
1
1
  import minifyAll from './dist/module.js';
2
2
 
3
- minifyAll('./test/', 'lib', { useBabel: true });
4
-
5
- // minifyAll('./test/', 'lib', {
6
- // presets: [
7
- // [
8
- // '@babel/preset-env',
9
- // {
10
- // targets: {
11
- // esmodules: false, // Target ES2015
12
- // },
13
- // },
14
- // ],
15
- // ],
16
- // });
17
- // console.log(process.argv.slice(2)[0], process.argv.slice(2)[1]);
18
- // minifyAll(process.argv.slice(2)[0], process.argv.slice(2)[1]);
3
+ minifyAll('./test/', {
4
+ excludeFolder: 'lib',
5
+ useBabel: {
6
+ targets: 'chrome 40',
7
+ },
8
+ });
package/dist/module.js CHANGED
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * uglify-js and minify-css for all files
3
3
  * Released under the terms of MIT license
4
- *
5
4
  * Copyright (C) 2024 yeongmin
6
5
  */
7
6
 
@@ -13,31 +12,29 @@ import { minifyJS, minifyCSS } from './modules/minifier.js';
13
12
  import babelCore from '@babel/core';
14
13
 
15
14
  const FILE_HANDLERS = {
16
- '.js': async (filePath, content, logger, babelOptions) => {
17
- try {
18
- // Transform the code using Babel with preset-env
19
- let transformed = content;
20
-
21
- // Convert code to Babel when Babel option is provided
22
- if (babelOptions) {
23
- transformed = babelCore.transformSync(content, babelOptions).code;
24
- }
25
-
26
- const result = minifyJS(transformed);
27
- await writeFile(filePath, result, logger);
28
- } catch (error) {
29
- await logger.logError(filePath, `Babel transformation failed: ${error.message}`);
30
- }
31
- },
32
- '.css': async (filePath, content, logger) => {
33
- const output = await minifyCSS(content);
34
- if (output.warnings.length > 0) {
35
- await logger.logError(filePath, `CSS warnings: ${output.warnings.join(', ')}`);
36
- await writeFile(filePath, null, logger);
37
- } else {
38
- await writeFile(filePath, output.styles, logger);
39
- }
40
- },
15
+ '.js': async (filePath, content, logger, babelOptions) => {
16
+ try {
17
+ let transformed = content;
18
+ if (babelOptions) {
19
+ transformed = babelCore.transformSync(content, babelOptions).code;
20
+ }
21
+ const result = minifyJS(transformed);
22
+ await writeFile(filePath, result, logger);
23
+ } catch (error) {
24
+ await logger?.error('JavaScript minification failed', { filePath, error: error.message });
25
+ }
26
+ },
27
+ '.css': async (filePath, content, logger) => {
28
+ try {
29
+ const output = await minifyCSS(content);
30
+ if (0 < output.warnings.length) {
31
+ await logger?.warn('CSS minification warnings', { filePath, warnings: output.warnings });
32
+ }
33
+ await writeFile(filePath, output.styles, logger);
34
+ } catch (error) {
35
+ await logger?.error('CSS minification failed', { filePath, error: error.message });
36
+ }
37
+ },
41
38
  };
42
39
 
43
40
  /**
@@ -49,43 +46,72 @@ const FILE_HANDLERS = {
49
46
  * @returns {Promise<void>}
50
47
  */
51
48
  async function processFile(filePath, logger, babelOptions = null) {
49
+ try {
52
50
  const fileContent = await fs.readFile(filePath, 'utf-8');
53
- const fileExtension = path.extname(filePath);
51
+ const fileExtension = path.extname(filePath).toLowerCase();
54
52
  const handler = FILE_HANDLERS[fileExtension];
55
53
 
56
54
  if (handler) {
57
- await handler(filePath, fileContent, logger, babelOptions);
55
+ await handler(filePath, fileContent, logger, babelOptions);
58
56
  } else {
59
- logger.logInfo(`지원되지 않는 파일 형식 건너뜀: ${filePath}`);
57
+ await logger?.info(`Unsupported file type, skipping: ${filePath}`);
60
58
  }
59
+ } catch (error) {
60
+ await logger?.error('Error processing file', { filePath, error: error.message });
61
+ }
61
62
  }
62
63
 
63
64
  /**
64
65
  * Resolves Babel options based on the provided configuration.
65
66
  *
66
- * @param {Object|null} options - The Babel options object or null.
67
+ * @param {Object|null} useBabel - The Babel options object or null.
67
68
  * @returns {Object|null} The resolved Babel options or null if no valid options are provided.
68
69
  */
69
- function resolveBabelOptions(options) {
70
- if (!options) return null;
70
+ function resolveBabelOptions(useBabel) {
71
+ if (!useBabel) return null;
72
+ return {
73
+ presets: [['@babel/preset-env', typeof useBabel === 'object' ? useBabel : {}]],
74
+ };
75
+ }
71
76
 
72
- if (options.useBabel) {
73
- return {
74
- presets: [
75
- [
76
- '@babel/preset-env',
77
- {
78
- targets: {
79
- esmodules: false, // Target ES2015
80
- },
81
- },
82
- ],
83
- ],
84
- };
85
- }
77
+ /**
78
+ * Options for Babel configuration.
79
+ *
80
+ * @typedef {Object} BabelOptions
81
+ * @property {string|string[]|Object<string, string>} [targets] - Specifies the target environments for the code.
82
+ * @property {'amd'|'umd'|'systemjs'|'commonjs'|'cjs'|'auto'|false} [modules] - Module format to use for the output.
83
+ * @property {boolean} [debug] - Enables or disables debug mode.
84
+ * @property {string[]} [include] - List of plugins or features to include.
85
+ * @property {string[]} [exclude] - List of plugins or features to exclude.
86
+ * @property {'usage'|'entry'|false} [useBuiltIns] - Determines how polyfills are added.
87
+ * @property {2|3|{version: 2|3, proposals: boolean}} [corejs] - Specifies the version of core-js to use and whether to include proposals.
88
+ * @property {boolean} [forceAllTransforms] - Forces the application of all transformations.
89
+ * @property {string} [configPath] - Path to the configuration file.
90
+ * @property {boolean} [ignoreBrowserslistConfig] - Ignores the browserslist configuration.
91
+ * @property {boolean} [shippedProposals] - Enables support for shipped proposals.
92
+ */
86
93
 
87
- return options.presets ? options : null;
88
- }
94
+ /**
95
+ * Options for logging configuration.
96
+ *
97
+ * @typedef {Object} LogOptions
98
+ * @property {string} [logDir] - Specifies the directory for log files.
99
+ * @property {number} [retentionDays] - Number of days to retain log files.
100
+ * @property {string} [logLevel] - Specifies the level of logging (e.g., 'info', 'warn', 'error').
101
+ * @property {string} [dateFormat] - Format for the date in log entries.
102
+ * @property {string} [timeZone] - Time zone for timestamps in log entries.
103
+ * @property {boolean} [logToConsole] - Determines if logs should also be output to the console.
104
+ * @property {boolean} [logToFile] - Determines if logs should be written to a file.
105
+ */
106
+
107
+ /**
108
+ * Options for minification configuration.
109
+ *
110
+ * @typedef {Object} MinifyOptions
111
+ * @property {string} [excludeFolder] - Folder to exclude from minification.
112
+ * @property {boolean|BabelOptions} [useBabel] - Whether to use Babel for transformation, and the options for Babel if used.
113
+ * @property {boolean|LogOptions} [useLog] - Whether to use logging, and the options for logging if used.
114
+ */
89
115
 
90
116
  /**
91
117
  * Minifies all JavaScript and CSS files in the specified directory and its subdirectories.
@@ -93,47 +119,38 @@ function resolveBabelOptions(options) {
93
119
  * @async
94
120
  * @function minifyAll
95
121
  * @param {string} contentPath - The path to the directory containing the files to be minified.
96
- * @param {string} [excludeFolder=''] - The name of a folder to exclude from minification.
97
- * @param {Object} [babelOptions=null] - Babel options for converting JavaScript files.
122
+ * @param {MinifyOptions} [options={}] - Options for minification, Babel, and logging.
98
123
  * @returns {Promise<void>} A promise that resolves when all files have been processed.
99
124
  * @throws {Error} If there's an issue reading or writing files.
100
- *
101
- * @example
102
- * // Minify all files in './test/' directory, excluding 'lib' folder
103
- * import minifyAll from './main.js';
104
- * await minifyAll('./test/', 'lib');
105
- *
106
- * @example
107
- * // Minify all files in a directory specified as a command line argument
108
- * import minifyAll from './main.js';
109
- * await minifyAll(process.argv[2], process.argv[3]);
110
- *
111
- * @example
112
- * // Add babel options for converting JavaScript files.
113
- * minifyAll('./test/', 'lib', {
114
- * presets: [
115
- * [
116
- * '@babel/preset-env',
117
- * {
118
- * targets: {
119
- * esmodules: false, // Target ES2015
120
- * },
121
- * },
122
- * ],
123
- * ],
124
- * });
125
125
  */
126
- export default async function minifyAll(contentPath, excludeFolder = '', babelOptions = null) {
127
- const logger = new Logger();
126
+ export default async function minifyAll(contentPath, options = {}) {
127
+ const { excludeFolder = '', useBabel = false, useLog = true, logOptions = {} } = options;
128
+
129
+ const logger = useLog ? new Logger(logOptions) : null;
130
+
131
+ if (logger) {
128
132
  await logger.initialize();
133
+ await logger.info('Starting minification process', { contentPath, excludeFolder, useBabel });
134
+ }
129
135
 
130
- const rootDir = contentPath || '';
131
- const finalBabelOptions = resolveBabelOptions(babelOptions);
136
+ const rootDir = path.resolve(contentPath || '');
137
+ const finalBabelOptions = resolveBabelOptions(useBabel);
132
138
 
139
+ try {
133
140
  await getAllFiles(rootDir, async (filePath) => {
134
- if (excludeFolder && filePath.includes(excludeFolder)) return;
135
- await processFile(filePath, logger, finalBabelOptions);
141
+ if (excludeFolder && path.relative(rootDir, filePath).startsWith(excludeFolder)) {
142
+ await logger?.debug('Skipping excluded file', { filePath });
143
+ return;
144
+ }
145
+
146
+ await processFile(filePath, logger, finalBabelOptions);
147
+ logger?.incrementProcessedFiles(filePath);
136
148
  });
149
+ } catch (error) {
150
+ await logger?.error('Error in minification process', { error: error.message });
151
+ }
137
152
 
153
+ if (logger) {
138
154
  await logger.summarize();
155
+ }
139
156
  }
@@ -15,16 +15,16 @@ import path from 'path';
15
15
  * @returns {Promise<void>}
16
16
  */
17
17
  export async function getAllFiles(dirPath, callback) {
18
- const files = await fs.readdir(dirPath);
19
- for (const file of files) {
20
- const filePath = path.join(dirPath, file);
21
- const fileStat = await fs.stat(filePath);
22
- if (fileStat.isFile()) {
23
- await callback(filePath, fileStat);
24
- } else if (fileStat.isDirectory()) {
25
- await getAllFiles(filePath, callback);
26
- }
18
+ const files = await fs.readdir(dirPath);
19
+ for (const file of files) {
20
+ const filePath = path.join(dirPath, file);
21
+ const fileStat = await fs.stat(filePath);
22
+ if (fileStat.isFile()) {
23
+ await callback(filePath, fileStat);
24
+ } else if (fileStat.isDirectory()) {
25
+ await getAllFiles(filePath, callback);
27
26
  }
27
+ }
28
28
  }
29
29
 
30
30
  /**
@@ -37,15 +37,15 @@ export async function getAllFiles(dirPath, callback) {
37
37
  * @returns {Promise<void>}
38
38
  */
39
39
  export async function writeFile(filePath, content, logger) {
40
- if (typeof content === 'undefined' || content === '' || content === null) {
41
- await logger.logError(filePath, 'Invalid or empty content');
42
- return;
43
- }
40
+ if (typeof content === 'undefined' || content === '' || content === null) {
41
+ await logger?.error('Invalid or empty content', { filePath });
42
+ return;
43
+ }
44
44
 
45
- logger.logInfo(`Writing file: ${filePath}`);
46
- try {
47
- await fs.writeFile(filePath, content, 'utf-8');
48
- } catch (error) {
49
- await logger.logError(filePath, `Write failed: ${error.message}`);
50
- }
45
+ await logger?.info(`Writing file: ${filePath}`);
46
+ try {
47
+ await fs.writeFile(filePath, content, 'utf-8');
48
+ } catch (error) {
49
+ await logger?.error(`Write failed: ${error.message}`, { filePath });
50
+ }
51
51
  }