question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Conditionals for file creation

See original GitHub issue

The current version supports conditionals inside files, but not about files. That is, I can include or exclude blocks of text depending on the truthiness of a value. I cannot, however, create files only if a certain value is truthy.

This would be hugely helpful in at least one case: the template I’m working on will support multiple deployment options (raw JAR, AWS, debian package…). Each method needs different files to be present in different paths.

Currently, I can either include everything and ask developers to manually delete what’s irrelevant, or include nothing and point them to a repo that contains the right files.

Ideally, they’d just answer a question (use AWS? [YES/no]) and everything would be set up.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
vptheroncommented, May 7, 2018

@notmu Thanks for the example, but it doesn’t seem to work for me. I see some strange behavior. I have this layout:

src/main/g8
├── resources
 |   ├── $if(use_sql.truthy)$sql_scripts$endif$
 |    |          |-- db_script.sql
...

If I set use_sql to yes during project creation I see the expected layout: resources/sql_scripts/db_script.sql. However, if I use no to set the value of use_sql I see the following layout in the output project: resources/db_script.sql. The file db_script.sql still gets included in the project, directly under resources.

Am I misunderstanding your example, or doing something wrong?

1reaction
eugeniykcommented, Jun 1, 2021

@ihostage I see, sorry for disturb actually my bad - I was using sbt which was older version since it was installed long time ago (1.3.3) running as sbt -sbt-version 1.5.3 new ... solves the problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

File input and output and conditionals - Elhanan Borenstein Lab
Take as arguments: 1) a string to find, 2) a string to replace with, 3) input file name, 4) output file name. You...
Read more >
Conditional Create File - NI Community - National Instruments
I would like to somehow create a conditional create file. Like this way a user can press a boolean button and that will...
Read more >
Lab 2: Conditionals and File I/O - University of Pittsburgh
In this lab you will learn about file i/o and at the same, you'll apply what you've already learned about conditional execution. OBJECTIVES....
Read more >
Conditional creation of files - global or scoped filehandle
You want to open a handle in a condition, then use the handle globally elsewhere. What if you don't open the file? Do...
Read more >
Document how to do conditional files/directories #723 - GitHub
Use logic in directory names to set whether or not something is created. (Only works in Linux/OSX).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found