Refactor route removal in cmd_render_route and cmd_remove to use sed for block deletion
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
parent
b8969bc6f7
commit
7072fc9a37
1 changed files with 3 additions and 2 deletions
|
|
@ -254,7 +254,8 @@ cmd_render_route() {
|
|||
|
||||
# Strip any existing block for this app from the aggregate file.
|
||||
if [[ -f "${APP_ROUTE_FILE}" ]]; then
|
||||
grep -v "^# route:${name}:" "${APP_ROUTE_FILE}" >"${tmp}" || true
|
||||
# Use sed to remove the block between # route:name:start and # route:name:end
|
||||
sed "/^# route:${name}:start$/,/^# route:${name}:end$/d" "${APP_ROUTE_FILE}" >"${tmp}" || true
|
||||
else
|
||||
printf "" >"${tmp}"
|
||||
fi
|
||||
|
|
@ -335,7 +336,7 @@ cmd_remove() {
|
|||
if [[ -f "${APP_ROUTE_FILE}" ]]; then
|
||||
local tmp
|
||||
tmp="$(mktemp)"
|
||||
grep -v "^# route:${name}:" "${APP_ROUTE_FILE}" >"${tmp}"
|
||||
sed "/^# route:${name}:start$/,/^# route:${name}:end$/d" "${APP_ROUTE_FILE}" >"${tmp}" || true
|
||||
mv "${tmp}" "${APP_ROUTE_FILE}"
|
||||
fi
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue