Skip to content

Instantly share code, notes, and snippets.

@discentem
Created March 13, 2017 05:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save discentem/6e7c203476249f68b1d0d0a1242eaad9 to your computer and use it in GitHub Desktop.
Save discentem/6e7c203476249f68b1d0d0a1242eaad9 to your computer and use it in GitHub Desktop.
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