File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -9,3 +9,46 @@ function AreEqual($a, $b) {
9
9
return $a -eq $b
10
10
}
11
11
}
12
+
13
+ function Read-PackageJson {
14
+ begin {
15
+ $ErrorActionPreference = ' SilentlyContinue'
16
+ }
17
+
18
+ process {
19
+ $cwd = Get-Location
20
+ $packagePath = Join-Path $cwd ' package.json'
21
+
22
+ if (-not (Test-Path $packagePath - PathType Leaf)) {
23
+ return $null
24
+ }
25
+
26
+ $packagePath = Resolve-Path $packagePath
27
+
28
+ return Get-Content $packagePath | ConvertFrom-Json
29
+ }
30
+ }
31
+
32
+ function Get-PackageScripts {
33
+ begin {
34
+ $ErrorActionPreference = ' SilentlyContinue'
35
+ }
36
+
37
+ process {
38
+ $package = Read-PackageJson
39
+
40
+ if ((-not $package ) -or (-not $package.scripts )) {
41
+ return $ ()
42
+ }
43
+
44
+ $scripts = $package.scripts | Get-Member - MemberType NoteProperty | ForEach-Object {
45
+ $_.Name
46
+ }
47
+
48
+ if (-not $scripts ) {
49
+ return $ ()
50
+ }
51
+
52
+ return $scripts
53
+ }
54
+ }
You can’t perform that action at this time.
0 commit comments