UNPKG

1.04 kBtext/coffeescriptView Raw
1GitHubApi = require 'github'
2_ = require 'lodash'
3url = require 'url'
4
5class Helpers
6 # extractMeshbluConnectorName: (appName) =>
7 # _.kebabCase appName
8
9 titleCase: (str) =>
10 "#{_.upperFirst(_.camelCase str)}"
11
12 githubUserInfo: (user, callback) =>
13 console.log('github user', user)
14 github = new GitHubApi version: '3.0.0'
15
16 console.log('process.env.GITHUB_TOKEN', process.env.GITHUB_TOKEN)
17 unless _.isEmpty process.env.GITHUB_TOKEN
18 github.authenticate
19 type: 'oauth'
20 token: process.env.GITHUB_TOKEN
21
22 github.user.getFrom {user}, callback
23
24 githubSlug: (githubUrl, appname) =>
25 parsedGithub = url.parse githubUrl
26 parts = parsedGithub.pathname.split '/'
27 return "#{parts[1]}/#{appname}"
28
29 mergeJSON: ({ input, overwriteWith }) =>
30 returnObj = _.cloneDeep(input)
31 _.each overwriteWith, (value, key) =>
32 if _.isPlainObject(value)
33 returnObj[key] = _.assign(returnObj[key], value)
34 return value
35 return returnObj
36
37module.exports = new Helpers