Skip to content

Instantly share code, notes, and snippets.

@zapplebee
Created April 13, 2021 15:47
Show Gist options
  • Save zapplebee/c5fbcd33fbe80edded0d14152f9aabbc to your computer and use it in GitHub Desktop.
Save zapplebee/c5fbcd33fbe80edded0d14152f9aabbc to your computer and use it in GitHub Desktop.
Track my mood
#!/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