Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions resources/Help/Microsoft.VSCode.Dsc/VSCodeExtension.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The `VSCodeExtension` DSC Resource allows you to install, update, and remove Vis
$params = @{
Name = 'ms-python.python'
}
Invoke-DscResource -Name VSCodeExtension -Method Set -Property $params -ModuleName Microsoft.VSCode.Dsc
Invoke-DscResource -ModuleName Microsoft.VSCode.Dsc -Name VSCodeExtension -Method Set -Property $params
```

### EXAMPLE 2
Expand All @@ -46,7 +46,7 @@ $params = @{
Name = 'ms-python.python'
Version = '2021.5.842923320'
}
Invoke-DscResource -Name VSCodeExtension -Method Set -Property $params -ModuleName Microsoft.VSCode.Dsc
Invoke-DscResource -ModuleName Microsoft.VSCode.Dsc -Name VSCodeExtension -Method Set -Property $params
```

### EXAMPLE 3
Expand All @@ -57,7 +57,7 @@ $params = @{
Name = 'ms-python.python'
Exist = $false
}
Invoke-DscResource -Name VSCodeExtension -Method Set -Property $params -ModuleName Microsoft.VSCode.Dsc
Invoke-DscResource -ModuleName Microsoft.VSCode.Dsc -Name VSCodeExtension -Method Set -Property $params
```

### EXAMPLE 4
Expand All @@ -68,5 +68,5 @@ $params = @{
Name = 'ms-python.python'
Insiders = $true
}
Invoke-DscResource -Name VSCodeExtension -Method Set -Property $params -ModuleName Microsoft.VSCode.Dsc
Invoke-DscResource -ModuleName Microsoft.VSCode.Dsc -Name VSCodeExtension -Method Set -Property $params
```
94 changes: 47 additions & 47 deletions resources/YarnDsc/YarnDsc.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,53 @@

using namespace System.Collections.Generic

#region Functions
function Assert-Yarn {
# Refresh session $path value before invoking 'npm'
$env:Path = [System.Environment]::GetEnvironmentVariable('Path', 'Machine') + ';' + [System.Environment]::GetEnvironmentVariable('Path', 'User')
try {
Invoke-Yarn -Command 'help'
return
} catch {
throw 'Yarn is not installed'
}
}

function Invoke-YarnInfo {
param(
[Parameter()]
[string]$Arguments
)

$command = [List[string]]::new()
$command.Add('info')
$command.Add($Arguments)
return Invoke-Yarn -Command $command
}

function Invoke-YarnInstall {
param (
[Parameter()]
[string]$Arguments
)

$command = [List[string]]::new()
$command.Add('install')
$command.Add($Arguments)
return Invoke-Yarn -Command $command
}

function Invoke-Yarn {
param (
[Parameter(Mandatory = $true)]
[string]$Command
)

return Invoke-Expression -Command "yarn $Command"
}

#endregion Functions

# Assert once that Yarn is already installed on the system.
Assert-Yarn

Expand Down Expand Up @@ -50,50 +97,3 @@ class YarnInstall {
}

#endregion DSCResources

#region Functions
function Assert-Yarn {
# Refresh session $path value before invoking 'npm'
$env:Path = [System.Environment]::GetEnvironmentVariable('Path', 'Machine') + ';' + [System.Environment]::GetEnvironmentVariable('Path', 'User')
try {
Invoke-Yarn -Command 'help'
return
} catch {
throw 'Yarn is not installed'
}
}

function Invoke-YarnInfo {
param(
[Parameter()]
[string]$Arguments
)

$command = [List[string]]::new()
$command.Add('info')
$command.Add($Arguments)
return Invoke-Yarn -Command $command
}

function Invoke-YarnInstall {
param (
[Parameter()]
[string]$Arguments
)

$command = [List[string]]::new()
$command.Add('install')
$command.Add($Arguments)
return Invoke-Yarn -Command $command
}

function Invoke-Yarn {
param (
[Parameter(Mandatory = $true)]
[string]$Command
)

return Invoke-Expression -Command "yarn $Command"
}

#endregion Functions
Loading