crisis-to-calm 1.0.1 → 1.0.2
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/index.js +11 -10
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import os from 'os';
|
|
4
4
|
import chalk from 'chalk';
|
|
@@ -8,7 +8,7 @@ import { fileURLToPath } from 'url';
|
|
|
8
8
|
|
|
9
9
|
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
10
10
|
const __dirname = path.resolve();
|
|
11
|
-
const statsFilePath = path.join(
|
|
11
|
+
const statsFilePath = path.join(__dirname, 'stats.json');
|
|
12
12
|
|
|
13
13
|
const themes = {
|
|
14
14
|
'--forest': { baseHex: '#00FF00', symbol: '♣ ', bg: chalk.hex('#004400') },
|
|
@@ -45,8 +45,7 @@ function updateStats(cyclesCompleted) {
|
|
|
45
45
|
|
|
46
46
|
try {
|
|
47
47
|
if (fs.existsSync(statsFilePath)) {
|
|
48
|
-
|
|
49
|
-
if (fileData.trim()) stats = JSON.parse(fileData);
|
|
48
|
+
stats = JSON.parse(fs.readFileSync(statsFilePath, 'utf8'));
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
const oldRank = stats.rank;
|
|
@@ -65,14 +64,16 @@ function updateStats(cyclesCompleted) {
|
|
|
65
64
|
}
|
|
66
65
|
// If it's a new day, check if it was yesterday
|
|
67
66
|
else {
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
const
|
|
67
|
+
const d = new Date();
|
|
68
|
+
d.setDate(d.getDate() - 1);
|
|
69
|
+
const yesterday = d.toISOString().split('T')[0];
|
|
71
70
|
|
|
72
|
-
if (stats.lastDate ===
|
|
73
|
-
stats.streak += 1;
|
|
71
|
+
if (stats.lastDate === yesterday) {
|
|
72
|
+
stats.streak += 1;
|
|
73
|
+
console.log("Streak continued! New streak:", stats.streak);
|
|
74
74
|
} else {
|
|
75
|
-
stats.streak = 1;
|
|
75
|
+
stats.streak = 1;
|
|
76
|
+
console.log("Streak reset to 1 (missed a day).");
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
stats.lastDate = today; // Mark today as the last breathing day
|