@@ -41,6 +41,7 @@ public class UseCompatibleCmdlets : AstVisitor, IScriptRule
41
41
private Dictionary < string , dynamic > platformSpecMap ;
42
42
private string scriptPath ;
43
43
private bool IsInitialized ;
44
+ private readonly string referenceFile = "desktop-5.1.14393.206-windows.json" ;
44
45
45
46
public UseCompatibleCmdlets ( )
46
47
{
@@ -271,7 +272,15 @@ private void SetupCmdletsDictionary()
271
272
switch ( mode )
272
273
{
273
274
case "offline" :
274
- ProcessOfflineModeArgs ( ruleArgs ) ;
275
+ var uri = GetStringArgFromListStringArg ( ruleArgs [ "uri" ] ) ;
276
+ if ( uri == null
277
+ || ! Directory . Exists ( uri )
278
+ || ! ContainsReferenceFile ( uri ) )
279
+ {
280
+ return ;
281
+ }
282
+
283
+ ProcessDirectory ( uri ) ;
275
284
break ;
276
285
277
286
case "online" : // not implemented yet.
@@ -284,14 +293,24 @@ private void SetupCmdletsDictionary()
284
293
}
285
294
286
295
var settingsPath = GetShippedSettingsDirectory ( ) ;
287
- if ( settingsPath == null )
296
+ if ( settingsPath == null
297
+ || ! ContainsReferenceFile ( settingsPath ) )
288
298
{
289
299
return ;
290
300
}
291
301
292
302
ProcessDirectory ( settingsPath ) ;
293
303
}
294
304
305
+ /// <summary>
306
+ /// Checks if the given directory has the reference file
307
+ /// directory must be non-null
308
+ /// </summary>
309
+ private bool ContainsReferenceFile ( string directory )
310
+ {
311
+ return File . Exists ( Path . Combine ( directory , referenceFile ) ) ;
312
+ }
313
+
295
314
/// <summary>
296
315
/// Resets the values in curCmdletCompatibilityMap to true
297
316
/// </summary>
0 commit comments