forked from Azure/azure-sdk-for-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInvoke-Codegeneration.ps1
More file actions
43 lines (35 loc) · 1016 Bytes
/
Invoke-Codegeneration.ps1
File metadata and controls
43 lines (35 loc) · 1016 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
35
36
37
38
39
40
41
42
43
<#
.SYNOPSIS
Invokes Autoest in the specified directory.
.DESCRIPTION
Invokes Autorest in the specified directory.
This script is all encompassing for running Autorest where it'll first ensure Autorest is installed then run Autorest.
.PARAMETER Directory
The directory where Autorest will be invoked.
.PARAMETER AutorestOptions
Additional options to pass to the Autorest command. By default, this will just run 'autorest'.
#>
param(
[Parameter(Mandatory = $true)]
[string]$Directory,
[Parameter(Mandatory = $false)]
[string]$AutorestOptions
)
# Ensure Autorest is installed.
npm install --error -g autorest
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to install Autorest."
exit 1
}
try {
Push-Location $Directory
if ($AutorestOptions) {
Write-Host "Running 'autorest $AutorestOptions' in directory '$Directory'."
Invoke-Expression "autorest $AutorestOptions"
} else {
Write-Host "Running 'autorest' in directory '$Directory'."
& autorest
}
} finally {
Pop-Location
}