Skip to content

Introduced --config CLI parameter to provide custom configuration file#190

Merged
psmyrek merged 1 commit intomasterfrom
i/189
Sep 15, 2025
Merged

Introduced --config CLI parameter to provide custom configuration file#190
psmyrek merged 1 commit intomasterfrom
i/189

Conversation

@psmyrek
Copy link
Copy Markdown
Contributor

@psmyrek psmyrek commented Sep 12, 2025

🚀 Summary

Introduced --config CLI parameter which allows providing custom configuration filename that will be used instead of the default mrgit.json file.


📌 Related issues


💡 Additional information

My test cases:

  1. Create custom mrgit-custom.json configuration file in this repository. Below you can find my example configuration:

    {
      "packages": "external/",
      "$rootRepository": "cksource/mrgit",
      "dependencies": {
        "ckeditor5-dev": "ckeditor/ckeditor5-dev",
        "ckeditor5-linters-config": "ckeditor/ckeditor5-linters-config"
      },
      "presets": {
        "dev": {
          "$rootRepository": "cksource/mrgit",
          "ckeditor5-dev": "ckeditor/ckeditor5-dev",
          "ckeditor5-linters-config": "ckeditor/ckeditor5-linters-config"
        }
      }
    }
  2. Execute mrgit commands:

    • node index.js - new --config CLI parameter is defined.
    • node index.js sync - throws "Cannot find the configuration file." error.
    • node index.js sync --config mrgit-custom.json - clones repositories into ./external directory.
    • node index.js save --config mrgit-custom.json --preset dev - stores hashes in mrgit-custom.json file in the dev preset.

}

options = Object.assign( options, callOptions );
const options = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that you refactored the code to use the immutable object creation pattern to create options.

*/
module.exports = function getOptions( callOptions, cwd ) {
const mrgitJsonPath = path.resolve( cwd, 'mrgit.json' );
module.exports = function getOptions( callOptions, cwd = process.cwd() ) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is cwd needed as an argument right now? It is not being used.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cwd parameter is required in tests 😒

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided that refactoring the tests was too much to do in this PR, so ¯\(ツ)/¯.

Copy link
Copy Markdown
Contributor

@martnpaneq martnpaneq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works fine :)

Image

@psmyrek psmyrek merged commit 1179720 into master Sep 15, 2025
4 checks passed
@psmyrek psmyrek deleted the i/189 branch September 15, 2025 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Define a custom config path

2 participants