Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix readme replacement #32

Merged
merged 1 commit into from Dec 12, 2023
Merged

Commits on Dec 9, 2023

  1. Append the array contents, not the array itself

    Without this, lines becomes:
    
    ```
    [
      ...,
      "<!-- SCHEMA_DEV: TEMPLATE #{key} - begin -->\n",
      "<!-- These lines are auto-inserted from a schema_dev template -->\n",
      [
        "template line 1\n",
        "template line 2\n",
        ...
      ],
      "\n",
      "<!-- SCHEMA_DEV: TEMPLATE #{key} - end -->\n",
      ...
    ]
    ```
    
    Then subsequent replacements fail because they choke on the array in the
    middle. Like:
    
    ```
    .../schema_dev-4.2.0/lib/schema_dev/readme.rb:68:in `!~': undefined method `=~' for ["As usual:\n", "\n", "```ruby\n", "gem \"<%= gem_name %>\"                # in a Gemfile\n", "gem.add_dependency \"<%= gem_name %>\" # in a .gemspec\n", "```\n"]:Array (NoMethodError)
    
      before = lines.take_while { |line| line !~ pattern }
                                              ^^
      from .../schema_dev-4.2.0/lib/schema_dev/readme.rb:68:in `block in replace_block'
    ```
    
    After this change:
    
    ```
    [
      ...,
      "<!-- SCHEMA_DEV: TEMPLATE #{key} - begin -->\n",
      "<!-- These lines are auto-inserted from a schema_dev template -->\n",
      "template line 1\n",
      "template line 2\n",
      ...,
      "\n",
      "<!-- SCHEMA_DEV: TEMPLATE #{key} - end -->\n",
      ...
    ]
    ```
    sj26 committed Dec 9, 2023
    Configuration menu
    Copy the full SHA
    e0b3861 View commit details
    Browse the repository at this point in the history