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

Wip/issue 21 multiple config files shortcuts #569

Merged

Conversation

ezzarghili
Copy link
Contributor

This fixes issue with multiple shortcuts when having multiple config files,tested with a play application using several config files.

val xml =
<DirectoryRef Id="ApplicationProgramsFolder">
<Component Id={ id } Guid={ makeGUID }>
{
var i = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

if you need an index use

for( (target, i) <- targets.zipWithIndex) yield { ... }

@muuki88 muuki88 added the windows label May 1, 2015
val name = simpleName(target)
val desc = "Edit configuration file: " + name
val cleanName = name.replaceAll("[\\.-\\\\//]+", "_")
<Shortcut Id={ id + "_SC" } Name={ cleanName } Description={ desc } Target={ "[INSTALLDIR]\\" + target.replaceAll("\\/", "\\\\") } WorkingDirectory="INSTALLDIR"/>
<Shortcut Id={ id + "_SC" + ("%0" + targets.size.toString().size + "d").format(i) } Name={ cleanName } Description={ desc } Target={ "[INSTALLDIR]\\" + target.replaceAll("\\/", "\\\\") } WorkingDirectory="INSTALLDIR"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

With scala 2.10 we can use string interpolation

s"$i${targets.size.toString.size}d")

@muuki88
Copy link
Contributor

muuki88 commented May 1, 2015

If I get this correctly, the shortcuts are generated based on the number of targets available.
So I got 3 targets, I will get short cut ids like this

val id = makeGuid
val targetSize = targets.size.toString.size
$id_SC_0$targetSize
$id_SC_1$targetSize
$id_SC_2$targetSize

If yes, you can put the targetSize in a variable, making it clear that it get's reused.

Otherwise this LGTM

@ezzarghili
Copy link
Contributor Author

Thanks for the reviews, actually I am not familiar with scala that was really helpful,
in the other hand yes the shortcuts are generated based on the number of targets available
but, I am using a string format to get a fixed length id string
so for 10 targets I will get

    $id_SC01
    $id_SC02
    ...
    $id_SC10

and for 100 targets

    $id_SC001
    ....
    $id_SC100

muuki88 added a commit that referenced this pull request May 1, 2015
…files_shortcuts

Wip/issue 21 multiple config files shortcuts
@muuki88 muuki88 merged commit d091090 into sbt:master May 1, 2015
@ezzarghili ezzarghili deleted the wip/issue_21_multiple_config_files_shortcuts branch May 3, 2015 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants