forked from atomantic/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
50 lines (45 loc) · 1.61 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const emoji = require('node-emoji')
const fs = require('fs')
const inquirer = require('inquirer')
const config = require('./config')
const command = require('./lib_node/command')
inquirer.prompt([{
type: 'confirm',
name: 'gitshots',
message: 'Do you want to use gitshots?',
default: true
}]).then(function (answers) {
if(answers.gitshots){
// additional brew packages needed to support gitshots
config.brew.push('imagemagick', 'imagesnap')
// ensure ~/.gitshots exists
command('mkdir -p ~/.gitshots', __dirname, function(err, out) {
if(err) throw err
})
// add post-commit hook
command('cp ./.git_template/hooks/gitshot-pc ./.git_template/hooks/post-commit', __dirname, function(err, out) {
if(err) throw err
})
}else{
if(fs.existsSync('./.git_template/hooks/post-commit')){
// disable post-commit (in case we are undoing the git-shots enable)
// TODO: examine and remove/comment out the file content with the git shots bit
command('mv ./.git_template/hooks/post-commit ./.git_template/hooks/disabled-pc', __dirname, function(err, out) {
if(err) throw err
})
}
}
const installPackages = function(type){
console.info(emoji.get('coffee'), ' installing '+type+' packages')
config[type].map(function(item){
console.info(type+':', item)
command('. lib_sh/echos.sh && . lib_sh/requirers.sh && require_'+type+' ' + item, __dirname, function(err, out) {
if(err) console.error(emoji.get('fire'), err)
})
})
}
installPackages('brew')
installPackages('cask')
installPackages('npm')
installPackages('gem')
})