Skip to content

Provide way to add options to your mapping #4

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

youwe-petervanderwal
Copy link

@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 2.0.0

Choose a reason for hiding this comment

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

Had to go with a major version bump because of the change in the interface

Choose a reason for hiding this comment

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

Maybe also remove PHP 7 compatibility then? See composer.json

|----------------------------------|----------------------------|--------------------------------|
| `file.php` | `file.php` | `file.php` |
| `{dot,.}gitignore` | `dotgitignore` | `.gitignore` |
| `{default/,}config.yaml{.dist,}` | `default/config.yaml.dist` | `config.yaml` |

Choose a reason for hiding this comment

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

I would like to suggest to use the | character. Not only is this a very common character in substitution formats it is also a character which you will never find in file names as it is reserved in both *nix and Windows based systems.

Choose a reason for hiding this comment

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

I'm only adding documentation here. This (with a comma) is how the mapping files already works (see https://github.com/YouweGit/testing-suite/blob/master/templates/mapping/files as example).

The actualy only change I introduce in this PR is the feature to provide options to the mapping, where I use the : separator (already a prohibited filename character in Windows -- UNIX allows a lot).

Although I do agree with you that | would have been a better choice than the , -- I think that changing that might be a bit out-of-scope and will require more refactoring

destinationDirectory: getcwd(),
mapping: '{templates/dot,.}gitignore'
'option1',
'option2'

Choose a reason for hiding this comment

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

Trailing comma.

sourceDirectory: __DIR__ . '/../folder/files',
targetDirectory: getcwd(),
'path/to/mapping-file-1',
'path/to/mapping-file-2'

Choose a reason for hiding this comment

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

Trailing comma.

@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 2.0.0

Choose a reason for hiding this comment

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

Maybe also remove PHP 7 compatibility then? See composer.json

/**
* @var string[]
*/
private $options;

Choose a reason for hiding this comment

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

Add typehint (depending on whether PHP 7 compatibility is removed)

return new UnixFileMapping(
$this->sourceDirectory,
$this->targetDirectory,
trim($mapping)
$mapping,
...$options

Choose a reason for hiding this comment

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

Trailing comma.
Should options be trimmed?

],
'files' =>
"{foo,bar}.php\n" .
"{templates/dot,.}gitignore:merge:force\n",

Choose a reason for hiding this comment

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

Should this break to the next line? And if so, shouldn't it be indented one more level?

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.

3 participants