Method: Hanami::Utils::Files.mkdir_p

Defined in:
lib/hanami/utils/files.rb

.mkdir_p(path) ⇒ Object

Creates a directory for the given path. It assumes that all the tokens, but the last, in path are meant to be a directory, whereas the last is meant to be a file. All the intermediate directories are created.

Examples:

require "hanami/utils/files"

Hanami::Utils::Files.mkdir_p("path/to/file.rb")
  # => creates the `path/to` directory, but NOT `file.rb`

# WRONG it doesn't create the last directory, check `.mkdir`
Hanami::Utils::Files.mkdir_p("path/to/directory")
  # => creates the `path/to` directory

Parameters:

  • path (String, Pathname)

    the path to directory

See Also:

Since:

  • 1.1.0



94
95
96
# File 'lib/hanami/utils/files.rb', line 94

def self.mkdir_p(path)
  Pathname.new(path).dirname.mkpath
end