neex 0.6.43 → 0.6.44
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/dist/src/logger.js +3 -1
- package/dist/src/watcher.js +25 -10
- package/package.json +1 -1
package/dist/src/logger.js
CHANGED
|
@@ -76,7 +76,9 @@ class Logger {
|
|
|
76
76
|
return chalk_1.default.hex(vibrantColors[colorIndex]);
|
|
77
77
|
}
|
|
78
78
|
formatPrefix(command) {
|
|
79
|
-
|
|
79
|
+
const color = this.commandColors.get(command) || chalk_1.default.white;
|
|
80
|
+
const prefix = `${command}:`.padEnd(this.prefixLength);
|
|
81
|
+
return color(prefix);
|
|
80
82
|
}
|
|
81
83
|
bufferOutput(output) {
|
|
82
84
|
const currentBuffer = this.outputBuffer.get(output.command) || [];
|
package/dist/src/watcher.js
CHANGED
|
@@ -32,7 +32,17 @@ const fs = __importStar(require("fs"));
|
|
|
32
32
|
const path = __importStar(require("path"));
|
|
33
33
|
const events_1 = require("events");
|
|
34
34
|
const chalk_1 = __importDefault(require("chalk"));
|
|
35
|
-
|
|
35
|
+
// A simple, self-contained logger for this module.
|
|
36
|
+
const logger = {
|
|
37
|
+
printLine: (message, level = 'info') => {
|
|
38
|
+
const prefix = {
|
|
39
|
+
info: chalk_1.default.blue('i'),
|
|
40
|
+
warn: chalk_1.default.yellow('!'),
|
|
41
|
+
error: chalk_1.default.red('x'),
|
|
42
|
+
}[level];
|
|
43
|
+
console.log(`${prefix} ${message}`);
|
|
44
|
+
},
|
|
45
|
+
};
|
|
36
46
|
class FileWatcher extends events_1.EventEmitter {
|
|
37
47
|
constructor(options) {
|
|
38
48
|
super();
|
|
@@ -121,7 +131,7 @@ class FileWatcher extends events_1.EventEmitter {
|
|
|
121
131
|
try {
|
|
122
132
|
const absolutePath = path.resolve(dirPath);
|
|
123
133
|
if (this.options.verbose) {
|
|
124
|
-
|
|
134
|
+
logger.printLine(`Watching directory: ${chalk_1.default.cyan(absolutePath)}`, 'info');
|
|
125
135
|
}
|
|
126
136
|
const watcher = fs.watch(absolutePath, { recursive: true }, async (eventType, filename) => {
|
|
127
137
|
if (!filename)
|
|
@@ -139,7 +149,7 @@ class FileWatcher extends events_1.EventEmitter {
|
|
|
139
149
|
}
|
|
140
150
|
catch (error) {
|
|
141
151
|
if (this.options.verbose) {
|
|
142
|
-
|
|
152
|
+
logger.printLine(`Failed to watch directory ${dirPath}: ${error.message}`, 'warn');
|
|
143
153
|
}
|
|
144
154
|
}
|
|
145
155
|
}
|
|
@@ -153,7 +163,7 @@ class FileWatcher extends events_1.EventEmitter {
|
|
|
153
163
|
return;
|
|
154
164
|
}
|
|
155
165
|
if (this.options.verbose) {
|
|
156
|
-
|
|
166
|
+
logger.printLine(`Watching file: ${chalk_1.default.cyan(absolutePath)}`, 'info');
|
|
157
167
|
}
|
|
158
168
|
const watcher = fs.watch(absolutePath, (eventType) => {
|
|
159
169
|
this.handleFileChange(absolutePath, eventType);
|
|
@@ -163,13 +173,13 @@ class FileWatcher extends events_1.EventEmitter {
|
|
|
163
173
|
}
|
|
164
174
|
catch (error) {
|
|
165
175
|
if (this.options.verbose) {
|
|
166
|
-
|
|
176
|
+
logger.printLine(`Failed to watch file ${filePath}: ${error.message}`, 'warn');
|
|
167
177
|
}
|
|
168
178
|
}
|
|
169
179
|
}
|
|
170
180
|
handleFileChange(filePath, eventType) {
|
|
171
181
|
if (this.options.verbose) {
|
|
172
|
-
|
|
182
|
+
logger.printLine(`File ${eventType}: ${chalk_1.default.yellow(path.relative(process.cwd(), filePath))}`, 'info');
|
|
173
183
|
}
|
|
174
184
|
// Debounce file changes
|
|
175
185
|
if (this.debounceTimer) {
|
|
@@ -188,7 +198,7 @@ class FileWatcher extends events_1.EventEmitter {
|
|
|
188
198
|
return;
|
|
189
199
|
}
|
|
190
200
|
this.isWatching = true;
|
|
191
|
-
|
|
201
|
+
logger.printLine('Starting file watcher...', 'info');
|
|
192
202
|
for (const watchPath of this.options.watch) {
|
|
193
203
|
const absolutePath = path.resolve(watchPath);
|
|
194
204
|
try {
|
|
@@ -201,15 +211,20 @@ class FileWatcher extends events_1.EventEmitter {
|
|
|
201
211
|
}
|
|
202
212
|
}
|
|
203
213
|
catch (error) {
|
|
204
|
-
|
|
214
|
+
logger.printLine(`Cannot watch ${watchPath}: ${error.message}`, 'warn');
|
|
205
215
|
}
|
|
206
216
|
}
|
|
217
|
+
const watchedCount = this.watchers.length;
|
|
218
|
+
logger.printLine(`File watcher started. Monitoring ${chalk_1.default.green(watchedCount)} locations`, 'info');
|
|
219
|
+
if (this.options.ext && this.options.ext.length > 0) {
|
|
220
|
+
logger.printLine(`Watching extensions: ${chalk_1.default.cyan(this.options.ext.join(', '))}`, 'info');
|
|
221
|
+
}
|
|
207
222
|
}
|
|
208
223
|
stop() {
|
|
209
224
|
if (!this.isWatching) {
|
|
210
225
|
return;
|
|
211
226
|
}
|
|
212
|
-
|
|
227
|
+
logger.printLine('Stopping file watcher...', 'info');
|
|
213
228
|
this.watchers.forEach(watcher => {
|
|
214
229
|
try {
|
|
215
230
|
watcher.close();
|
|
@@ -225,7 +240,7 @@ class FileWatcher extends events_1.EventEmitter {
|
|
|
225
240
|
clearTimeout(this.debounceTimer);
|
|
226
241
|
this.debounceTimer = null;
|
|
227
242
|
}
|
|
228
|
-
|
|
243
|
+
logger.printLine('File watcher stopped', 'info');
|
|
229
244
|
}
|
|
230
245
|
isActive() {
|
|
231
246
|
return this.isWatching;
|