forked from atomantic/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
72 lines (67 loc) · 2.19 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const emoji = require('node-emoji')
const fs = require('fs')
const inquirer = require('inquirer')
const config = require('./config')
const command = require('./lib_node/command')
const series = require('async.series')
inquirer.prompt([{
type: 'confirm',
name: 'gitshots',
message: 'Do you want to use gitshots?',
default: false
},{
type: 'confirm',
name: 'packages',
message: 'Do you want to install packages from config.js?',
default: false
}]).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
})
}
}
if(!answers.packages){
return console.log('skipping package installs')
}
const tasks = [];
['brew', 'cask', 'npm', 'gem', 'mas', 'wget'].forEach( type => {
if(config[type] && config[type].length){
tasks.push((cb)=>{
console.info(emoji.get('coffee'), ' installing '+type+' packages')
cb()
})
config[type].forEach((item)=>{
tasks.push((cb)=>{
console.info(type+':', item)
command('. lib_sh/echos.sh && . lib_sh/requirers.sh && require_'+type+' ' + item, __dirname, function(err, stdout, stderr) {
if(err) console.error(emoji.get('fire'), err, stderr)
cb()
})
})
})
}else{
tasks.push((cb)=>{
console.info(emoji.get('coffee'), type+' has no packages')
cb()
})
}
})
series(tasks, function(err, results) {
console.log('package install complete')
})
})