@@ -279,10 +279,11 @@ export function getBoolInput(name: string, required?: boolean): boolean {
279279
280280/**
281281 * Gets the value of an feature flag and converts to a bool.
282- *
282+ * @IMPORTANT This method is only for internal Microsoft development. Do not use it for external tasks.
283283 * @param name name of the feature flag to get.
284284 * @param defaultValue default value of the feature flag in case it's not found in env. (optional. Default value = false)
285285 * @returns boolean
286+ * @deprecated Don't use this for new development. Use getPipelineFeature instead.
286287 */
287288export function getBoolFeatureFlag ( ffName : string , defaultValue : boolean = false ) : boolean {
288289 const ffValue = process . env [ ffName ] ;
@@ -297,6 +298,28 @@ export function getBoolFeatureFlag(ffName: string, defaultValue: boolean = false
297298 return ffValue . toLowerCase ( ) === "true" ;
298299}
299300
301+ /**
302+ * Gets the value of an task feature and converts to a bool.
303+ * @IMPORTANT This method is only for internal Microsoft development. Do not use it for external tasks.
304+ * @param name name of the feature to get.
305+ * @returns boolean
306+ */
307+ export function getPipelineFeature ( featureName : string ) : boolean {
308+ const variableName = im . _getVariableKey ( `DistributedTask.Tasks.${ featureName } ` ) ;
309+ const featureValue = process . env [ variableName ] ;
310+
311+ if ( ! featureValue ) {
312+ debug ( `Feature '${ featureName } ' not found. Returning false as default.` ) ;
313+ return false ;
314+ }
315+
316+ const boolValue = featureValue . toLowerCase ( ) === "true" ;
317+
318+ debug ( `Feature '${ featureName } ' = '${ featureValue } '. Processed as '${ boolValue } '.` ) ;
319+
320+ return boolValue ;
321+ }
322+
300323/**
301324 * Gets the value of an input and splits the value using a delimiter (space, comma, etc).
302325 * Empty values are removed. This function is useful for splitting an input containing a simple
@@ -801,7 +824,7 @@ export function mkdirP(p: string): void {
801824 let testDir : string = p ;
802825 while ( true ) {
803826 // validate the loop is not out of control
804- if ( stack . length >= ( process . env [ 'TASKLIB_TEST_MKDIRP_FAILSAFE' ] || 1000 ) ) {
827+ if ( stack . length >= Number ( process . env [ 'TASKLIB_TEST_MKDIRP_FAILSAFE' ] || 1000 ) ) {
805828 // let the framework throw
806829 debug ( 'loop is out of control' ) ;
807830 fs . mkdirSync ( p ) ;
0 commit comments