You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 16, 2020. It is now read-only.
/// Called after your application has initialized.
public func boot(_ app: Application) throws {
if app.environment == .yesRelease {
// this won't get run
}
}
I thought I made a mistake in my code when the app's Environment didn't match my custom Environment. If there's no way to use a custom Environment where isRelease is true, it shouldn't be possible to create one.
The text was updated successfully, but these errors were encountered:
rausnitz
changed the title
Custom environments can't set isRelease to true
Can't use custom environments when isRelease is true
Feb 5, 2019
Moving this issue to vapor/service since that's where Environment lives.
Yeah this is a problem with the current design.
I think going forward it would make more sense for Environment.isRelease to be an easy way to check if the app has been compiled with -c release or not. Right now there are checks for both Environment.isRelease and _isDebugAssertConfiguration in different places, leading to subtle differences in behavior.
The other option is to split --env into --envName and --envIsRelease or come up with some format like --env yesRelease:true for specifying isRelease.
Environment.isRelease now returns true when the program has been compiled with optimizations (-c release). See #29. This change will come with ServiceKit 2.0.
As far as I can tell there's no way to use a custom
Environment
whereisRelease
istrue
.Here's a custom
Environment
example:I've created the
yesRelease
environment but I can't seem to use it. When I runvapor run --env=yesRelease
, the environment that gets created will always haveisRelease
set tofalse
. https://github.com/vapor/console/blob/master/Sources/Command/Run/CommandInput.swift#L179Then if I try to see whether the
Environment
equals my customEnvironment
, it will fail, because two environments must share the samename
andisRelease
properties in order to be equal. https://github.com/vapor/service/blob/master/Sources/Service/Environment/Environment.swift#L46I thought I made a mistake in my code when the app's
Environment
didn't match my customEnvironment
. If there's no way to use a customEnvironment
whereisRelease
istrue
, it shouldn't be possible to create one.The text was updated successfully, but these errors were encountered: