@@ -279,10 +279,11 @@ export function getBoolInput(name: string, required?: boolean): boolean {
279
279
280
280
/**
281
281
* 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.
283
283
* @param name name of the feature flag to get.
284
284
* @param defaultValue default value of the feature flag in case it's not found in env. (optional. Default value = false)
285
285
* @returns boolean
286
+ * @deprecated Don't use this for new development. Use getPipelineFeature instead.
286
287
*/
287
288
export function getBoolFeatureFlag ( ffName : string , defaultValue : boolean = false ) : boolean {
288
289
const ffValue = process . env [ ffName ] ;
@@ -297,6 +298,28 @@ export function getBoolFeatureFlag(ffName: string, defaultValue: boolean = false
297
298
return ffValue . toLowerCase ( ) === "true" ;
298
299
}
299
300
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
+
300
323
/**
301
324
* Gets the value of an input and splits the value using a delimiter (space, comma, etc).
302
325
* 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 {
801
824
let testDir : string = p ;
802
825
while ( true ) {
803
826
// 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 ) ) {
805
828
// let the framework throw
806
829
debug ( 'loop is out of control' ) ;
807
830
fs . mkdirSync ( p ) ;
0 commit comments