-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathForFile.ps1
More file actions
35 lines (31 loc) · 825 Bytes
/
ForFile.ps1
File metadata and controls
35 lines (31 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<#
.SYNOPSIS
Gets the language for a file.
.DESCRIPTION
Gets the PipeScript language definitions for a path.
.EXAMPLE
$PSLanguage.ForFile("a.xml")
.EXAMPLE
$PSInterpreters.ForFile("a.js")
#>
param(
# The path to the file, or the name of the command.
[string]
$FilePath
)
foreach ($excludePattern in $this.ExcludePattern) {
if ($filePath -match $excludePattern) { return }
}
foreach ($excludePath in $this.ExcludePath) {
if (-not $excludePath) { continue }
if ($filePath -like $excludePath) { return }
}
foreach ($prop in $this.psobject.properties) {
if ($prop -is [psscriptproperty]) { continue }
if ($prop.IsInstance -and
$prop.Value.LanguageName -and
$prop.Value.FilePattern -and
$filePath -match $prop.Value.FilePattern) {
$prop.Value
}
}