Created
March 13, 2017 05:36
-
-
Save discentem/6e7c203476249f68b1d0d0a1242eaad9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
require 'mixlib/shellout' | |
resource_name :BK_atom | |
default_action :config | |
action :config do | |
manage_atom | |
end | |
action_class do | |
def manage_atom | |
case node['platform_family'] | |
when 'mac_os_x' | |
manage_atom_osx | |
end | |
end | |
def manage_atom_osx | |
prefs = node['BK_atom_config'] | |
prefs = prefs.reject { |_k, v| v.nil? } | |
return if prefs.empty? | |
current_user = Mixlib::ShellOut.new("logname") | |
current_user.run_command | |
current_user = current_user.stdout.strip | |
atom_prefs_dir = "/Users/#{current_user}/.atom" | |
directory atom_prefs_dir do | |
owner current_user | |
mode '0755' | |
recursive true | |
action :create | |
end | |
file atom_prefs_dir + '/config.cson' do | |
owner current_user | |
mode '0755' | |
action :create | |
content Chef::JSONCompat.to_json_pretty(prefs) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment