1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-15 10:46:32 +00:00

Add wakatime-plugin #2810

This commit is contained in:
Luis Reinoso
2019-03-12 20:02:24 -05:00
parent 78c00b1722
commit 6dc88262c9
2 changed files with 39 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
const exec = require('child_process').exec
const path = require('path')
let lastHeartbeat = 0
function sendWakatimeHeartBeat (storagePath, noteKey, storageName, isWrite, hasFileChanges, isFileChange) {
if (new Date().getTime() - lastHeartbeat > 120000 || isFileChange) {
const notePath = path.join(storagePath, 'notes', noteKey + '.cson')
if (!isWrite && !hasFileChanges && !isFileChange) {
return
}
// TODO: add --key sdasdsa-sdsad-asdasd-asdsa-asdasdadas from configuration UI or use ~/.wakatime.conf
exec(`wakatime --file ${notePath} --project ${storageName} --plugin Boostnote-wakatime`, (error, stdOut, stdErr) => {
if (error) {
console.log(error)
} else {
lastHeartbeat = new Date()
console.log('wakatime', 'isWrite', isWrite, 'hasChanges', hasFileChanges)
}
})
}
}
export { sendWakatimeHeartBeat }