Last active
August 29, 2015 13:56
-
-
Save bluSch/9210142 to your computer and use it in GitHub Desktop.
Create all directories in a path with chef
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
# This function is equivalent to `execute "mkdir -p #{path}"` | |
# path is the path to be created, and can only be absolute without tweaking this | |
require 'pathname' | |
def create_path path | |
split_path = Pathname(path).each_filename.to_a | |
split_path.each_with_index.map do | _, index | | |
partial_path = File.join(File::SEPARATOR, split_path.slice(0, index + 1)) | |
directory partial_path | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment