Created
April 13, 2021 15:47
-
-
Save zapplebee/c5fbcd33fbe80edded0d14152f9aabbc to your computer and use it in GitHub Desktop.
Track my mood
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
const child_process = require("child_process"); | |
const path = require("path"); | |
const os = require("os"); | |
let mood = process.argv[2]; | |
switch (mood) { | |
case "1": | |
mood = 1; | |
break; | |
case "2": | |
mood = 2; | |
break; | |
case "3": | |
mood = 3; | |
break; | |
default: | |
console.log(`Enter a mood: | |
1: good | |
2: even | |
3: bad`); | |
process.exit(1); | |
} | |
const moodPath = path.join(os.homedir(), `mood.csv`); | |
child_process.exec(`touch ${moodPath}`); | |
child_process.exec( | |
`echo "${new Date().toISOString()}, ${mood}" >> ${moodPath}` | |
); | |
console.log(moodPath); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment