Sha256: d4ba21ccf359081c8234e35613494bc9d2735faa80a6d6fa8d15d874cd9c27f9
Contents?: true
Size: 726 Bytes
Versions: 20
Compression:
Stored size: 726 Bytes
Contents
# frozen_string_literal: true # check if a file exists Puppet::Functions.create_function(:'file::exists', Puppet::Functions::InternalFunction) do # @param filename Absolute path or Puppet file path. # @example Check a file on disk # file::exists('/tmp/i_dumped_this_here') # @example check a file from the modulepath # file::exists('example/files/VERSION') dispatch :exists do scope_param required_param 'String', :filename return_type 'Boolean' end def exists(scope, filename) Puppet.lookup(:bolt_executor) {}&.report_function_call(self.class.name) found = Puppet::Parser::Files.find_file(filename, scope.compiler.environment) found && Puppet::FileSystem.exist?(found) end end
Version data entries
20 entries across 20 versions & 1 rubygems