@getty.io/taskapp
Advanced tools
Comparing version 1.0.11 to 1.2.1
@@ -8,4 +8,24 @@ 'use strict' | ||
const userName = require('git-user-name'); | ||
const createEvent = require('./mixpanel.js'); | ||
const username = userName(); | ||
console.warn(chalk.green('username: '+username)); | ||
const factoryTime = (spent) => { | ||
let hour = 0; | ||
let min = 0; | ||
if (/h/.test(spent)) { | ||
hour = parseInt(spent.match(/\d+(?=h)/g)[0]); | ||
} | ||
if (/m/.test(spent)) { | ||
min = spent.match(/\d+(?=m)/g) | ||
if (spent.match(/\d+(?=m)/g)) min = min[0]; | ||
min = (min*1)/60; | ||
} | ||
return (hour+min).toFixed(2); | ||
} | ||
const getOptions = () => { | ||
@@ -21,4 +41,6 @@ try { | ||
const messageValidator = (msg)=> { | ||
const messageValidator = (msg) => { | ||
const project = getOptions().name; | ||
let hasError = false; | ||
let scope, task, spent = ''; | ||
@@ -54,9 +76,15 @@ if (!(/task/.test(msg))) { | ||
} else { | ||
scope = msg.match(/(^\S+:)/g)[0].slice(0, -1); | ||
task = msg.match(/task:.+,/g)[0].replace('task:', '').trim().slice(0, -1); | ||
spent = msg.match(/spent:.+/g)[0].replace('spent:', '').trim(); | ||
createEvent(project, username, scope, task, factoryTime(spent)); | ||
console.warn(chalk.green(`Thanks ${username}, your task was validated with success! Great job! Your earned 2 points!`)); | ||
// TODO: send to api | ||
process.exit(0); | ||
// process.exit(0); | ||
} | ||
} | ||
const validator = (message)=> { | ||
const validator = (message = 'feat: Mixpanel event, task: https://trello.com/c/cmsTXwve/1-mixpanel-event, spent: 33m') => { | ||
try { | ||
@@ -63,0 +91,0 @@ messageValidator(message) |
{ | ||
"name": "@getty.io/taskapp", | ||
"version": "1.0.11", | ||
"version": "1.2.1", | ||
"description": "Getty/IO commit-msg hook validator", | ||
@@ -22,6 +22,5 @@ "main": "index.js", | ||
"find-root": "^1.0.0", | ||
"fs": "^0.0.1-security", | ||
"git-user-name": "^2.0.0", | ||
"husky": "^0.15.0-beta.16", | ||
"path": "^0.12.7" | ||
"mixpanel": "^0.8.0" | ||
}, | ||
@@ -28,0 +27,0 @@ "husky": { |
Sorry, the diff of this file is not supported yet
21007
6
7
112
+ Addedmixpanel@^0.8.0
+ Addedagent-base@4.3.0(transitive)
+ Addeddebug@3.2.7(transitive)
+ Addedes6-promise@4.2.8(transitive)
+ Addedes6-promisify@5.0.0(transitive)
+ Addedhttps-proxy-agent@2.1.1(transitive)
+ Addedmixpanel@0.8.0(transitive)
+ Addedms@2.1.3(transitive)
- Removedfs@^0.0.1-security
- Removedpath@^0.12.7
- Removedfs@0.0.1-security(transitive)
- Removedinherits@2.0.3(transitive)
- Removedpath@0.12.7(transitive)
- Removedprocess@0.11.10(transitive)
- Removedutil@0.10.4(transitive)