You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: rakelib/update.rake
+60Lines changed: 60 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -48,6 +48,66 @@ namespace :update do
48
48
update_dirsubrepo['directory']
49
49
end
50
50
end
51
+
52
+
desc"Find and replace links from 'tmp/migrated-from-to.csv' in files at the provided directory.
53
+
Arguments:
54
+
- 'dir' is an absolute path to the directory to process the links. Required.
55
+
- 'exclude' is an fnmatch pattern for paths to exclude from processing. For fnmatch format, see https://ruby-doc.org/core-2.7.5/Dir.html#method-c-glob. Optional.
abort'FAILED. Missing "tmp/migrated-from-to.csv" file. Make sure that your _config.local.yml file contains the "migrated_log: generate_file" parameter.'
64
+
end
65
+
# check if the provided directory ('dir') exist
66
+
dir=File.expand_path(ENV['dir'])
67
+
unlessdir
68
+
abort'FAILED. Missing argument "dir". Provide a directory to check the links. Example: rake update:migrated_links_at dir=path/to/codebase'
69
+
end
70
+
unlessDir.exist?(dir)
71
+
abort"FAILED. Check the path provided through the 'dir' argument. The provide directory does not exist: #{dir}"
72
+
end
73
+
exclude=ENV['exclude']
74
+
# parse 'tmp/migrated-from-to.csv'
75
+
links=CSV.readlinks_file
76
+
# for each file in dir, find and replace all links
77
+
puts'Work in progress...'.magenta
78
+
dir_glob_pattern=File.join(dir,'**','*')
79
+
full_file_list=Dir[dir_glob_pattern]
80
+
# exclude paths by pattern from the file list if the 'exclude' argument was added
0 commit comments