diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-01 20:23:36 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-01 20:23:36 +0200 |
| commit | e17fbbfb30da394d6abbb91da4a963ff8913ad47 (patch) | |
| tree | a25fcbf4e9f6e5c4d1a1b0a763a32f05d9758bcd /lib/dslkeywords | |
| parent | 990c817571844462906b4ac7a58e64640be660e2 (diff) | |
fix dry-run crash when parent directory does not exist yet, add rake and rcm fallback to examples
Diffstat (limited to 'lib/dslkeywords')
| -rw-r--r-- | lib/dslkeywords/file.rb | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/dslkeywords/file.rb b/lib/dslkeywords/file.rb index 9a44f72..927054a 100644 --- a/lib/dslkeywords/file.rb +++ b/lib/dslkeywords/file.rb @@ -211,6 +211,14 @@ module RCM end def write!(text) + # In dry-run mode skip all filesystem access and just report what would + # happen — the parent directory may not exist yet so we cannot write the + # temporary file at all. + if option :dry + info "Writing file #{@file_path} - dry run!" + return + end + tmp_path = "#{@file_path}.rcmtmp" ::File.write(tmp_path, text) @@ -223,9 +231,8 @@ module RCM backup!(@file_path, checksum) # File changed, backup! end - do? "Writing file #{@file_path}" do - ::File.rename(tmp_path, @file_path) - end + info "Writing file #{@file_path}" + ::File.rename(tmp_path, @file_path) ::File.delete(tmp_path) if ::File.file?(tmp_path) end end |
