Sha256: 62d5c09a9ce25e37d1e6c93ef3a7794009a26bf2ecb9abd04463908e42c5340d
Contents?: true
Size: 733 Bytes
Versions: 11
Compression:
Stored size: 733 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) : false end end
Version data entries
11 entries across 11 versions & 1 rubygems