This article provides a way to get the stack where an app is targeted to during staging.
You might want to customize a buildpack where you want to put logic so it can support either Windows or Linux stack but how would you determine what particular stack was an app targeted to during staging?
Cloud Controller sets the CF_STACK
environment variable to the stack name during staging but not during the launch.
CF_STACK
environment variable sample values are cflinuxfs2, windows2012R2