From 5458409b9119df97d2373facafb7f8869d304318 Mon Sep 17 00:00:00 2001 From: Adam Eivy Date: Fri, 10 Feb 2017 09:17:15 -0800 Subject: [PATCH] make gitshots optional --- HISTORY.md | 3 ++- README.md | 6 ++--- config.js | 2 -- index.js | 70 +++++++++++++++++++++++++++++++++--------------------- 4 files changed, 47 insertions(+), 34 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index e81077038..cb0aba919 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -29,7 +29,8 @@ * disable vim YouCompleteMe Bundle (wasn't using it anyway and was causing installation problems on some machines) * remove yo, generator-dockerize, box-sync from software installs * install node stable (rather than old 4.x.x version) - + * make gitshots optional (and only install `imagesnap` and `imagemagick` if this is on) + ## v4.3.0 * vim installation fix * Enable firewall diff --git a/README.md b/README.md index 450243d16..1c9343204 100644 --- a/README.md +++ b/README.md @@ -331,8 +331,8 @@ The following is the software that I have set as default: * gnu-sed * homebrew/dupes/grep * httpie -* imagemagick -* imagesnap +* imagemagick (only if gitshots enabled) +* imagesnap (only if gitshots enabled) * jq * mas * moreutils @@ -361,14 +361,12 @@ The following is the software that I have set as default: * antic * buzzphrase * eslint -* generator-dockerize * gulp * instant-markdown-d * npm-check * prettyjson * trash * vtop -* yo ## Ruby Gems * git-up diff --git a/config.js b/config.js index b9c533568..532c509e2 100644 --- a/config.js +++ b/config.js @@ -21,8 +21,6 @@ module.exports = { 'homebrew/dupes/grep', // https://github.com/jkbrzt/httpie 'httpie', - 'imagemagick', - 'imagesnap', // jq is a sort of JSON grep 'jq', // Mac App Store CLI: https://github.com/mas-cli/mas diff --git a/index.js b/index.js index 8c9b57add..731cf44ad 100644 --- a/index.js +++ b/index.js @@ -1,34 +1,50 @@ const emoji = require('node-emoji') -// const inquirer = require('inquirer') +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){ -// // ensure ~/.gitshots exists -// command('mkdir -p ~/.gitshots', __dirname, function(err, out) { -// if(err) console.error(err) -// }); -// } +inquirer.prompt([{ + type: 'confirm', + name: 'gitshots', + message: 'Do you want to use gitshots?', + default: true +}]).then(function (answers) { + if(answers.gitshots){ -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) - }); - }); -} + // 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 + }) + } + } -installPackages('brew'); -installPackages('cask'); -installPackages('npm'); -installPackages('gem'); + 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') + +})