cwresdev 0.2.3 → 0.2.4
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/package.json +1 -1
- package/src/cwgit.js +12 -2
package/package.json
CHANGED
package/src/cwgit.js
CHANGED
|
@@ -361,12 +361,22 @@ function sanitizeCsvCell(value) {
|
|
|
361
361
|
|
|
362
362
|
const STATUS_LABELS = { M: "Modified", U: "Untracked", D: "Deleted" };
|
|
363
363
|
|
|
364
|
+
function formatLocalDate(date) {
|
|
365
|
+
const y = date.getFullYear();
|
|
366
|
+
const m = String(date.getMonth() + 1).padStart(2, "0");
|
|
367
|
+
const d = String(date.getDate()).padStart(2, "0");
|
|
368
|
+
const h = String(date.getHours()).padStart(2, "0");
|
|
369
|
+
const min = String(date.getMinutes()).padStart(2, "0");
|
|
370
|
+
const s = String(date.getSeconds()).padStart(2, "0");
|
|
371
|
+
return `${y}-${m}-${d} ${h}:${min}:${s}`;
|
|
372
|
+
}
|
|
373
|
+
|
|
364
374
|
/**
|
|
365
375
|
* Export changes to a CSV file.
|
|
366
376
|
*/
|
|
367
377
|
async function exportCsv(changes, outputDir) {
|
|
368
378
|
const csvPath = path.join(outputDir, "cwgit-changes.csv");
|
|
369
|
-
const lines = ["
|
|
379
|
+
const lines = ["File,Status,Date"];
|
|
370
380
|
|
|
371
381
|
for (const { file, status, mtime } of changes) {
|
|
372
382
|
const safeFile = sanitizeCsvCell(file);
|
|
@@ -374,7 +384,7 @@ async function exportCsv(changes, outputDir) {
|
|
|
374
384
|
? `"${safeFile.replace(/"/g, '""')}"`
|
|
375
385
|
: safeFile;
|
|
376
386
|
const label = STATUS_LABELS[status] || status;
|
|
377
|
-
const date = mtime ? mtime
|
|
387
|
+
const date = mtime ? formatLocalDate(mtime) : "";
|
|
378
388
|
lines.push(`${escaped},${label},${date}`);
|
|
379
389
|
}
|
|
380
390
|
|