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

Add :run-options config #10

Merged
merged 1 commit into from Jul 30, 2018
Merged

Conversation

endenwer
Copy link
Contributor

Add ability to set options for react-native run-*.

@endenwer
Copy link
Contributor Author

This required for status-im/status-mobile#5304

@@ -178,10 +178,16 @@
(future (shell/exec full-command))
(shell/exec full-command)))))

(defn get-run-options
[build-id config]
(or (get-in config [:platforms build-id :run-options]) (:run-options config)))
Copy link
Member

Choose a reason for hiding this comment

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

maybe better to merge them?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about this?

(defn- get-platform-config
  [config platform]
  (merge config (get-in config [:platforms platform])))

(defn- run-builds
  [build-ids config]
  (doseq [build-id build-ids]
    (let [platform-config (get-platform-config config build-id)
          command (str "run-" (name build-id) " " (:run-options platform-config))]
      (execute-react-native-cli command))))

Copy link
Member

Choose a reason for hiding this comment

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

i'm not sure if merge works for strings, and see Julien comment below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't, but I don't merge strings here. Platform config is a map.

Copy link
Member

Choose a reason for hiding this comment

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

ok cool then

@flexsurfer flexsurfer requested a review from dmitryn July 26, 2018 13:59
:run-options ""

;; platform specific config. Supported only `:run-options`
:platform {:android {:run-options "--appPrefix debug"}}}
Copy link
Contributor

Choose a reason for hiding this comment

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

How about having :run-options {:android "" :ios "" :default ""} ?

Also do platform specifics override the default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reasons why I made it like this:

Platform specific config overrides default.

Copy link
Contributor

Choose a reason for hiding this comment

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

From a user perspective having a single option makes more sense. Would this prevent the other PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It requires more work to do it like this if it should be similar for all options and I need to change pr for status-react. If only for :runs-options then it is easier.

Copy link
Contributor

Choose a reason for hiding this comment

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

if it should be similar for all options

What do you mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is for the future so all options would look the same. If it is not required now I can do it only for :run-options.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes let's try to find out what the best solution would be to be future proof. Then only implement it for run-options

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok. So I do :run-options like this :run-options {:android "" :ios "" :default ""}?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that's the cleanest way to do this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, I will do it like this.

@@ -10,7 +10,7 @@

(defn exec
[command]
(let [process (.exec (Runtime/getRuntime) (into-array (str/split command #" ")))]
(let [process (.exec (Runtime/getRuntime) (into-array ["sh" "-c" command]))]
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you detail this? How will windows be impacted here?

Copy link
Contributor Author

@endenwer endenwer Jul 27, 2018

Choose a reason for hiding this comment

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

Runtime/getRuntime require command as an array.
This command

command run --first-arg="something here" --second-arg="something here" --last-arg

should be separated like this

command
run 
--first-arg="something here"
--second-arg="something here" 
--last-arg

I can split string with this regexp \s+(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$) if it should work on windows.

@endenwer
Copy link
Contributor Author

@jeluard I changed :run-options.

@jeluard jeluard merged commit d9b8357 into status-im:master Jul 30, 2018
@jeluard
Copy link
Contributor

jeluard commented Jul 30, 2018

Awesome @endenwer ! I just merged it!

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.

None yet

3 participants