-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5db8f0f
commit f08c283
Showing
6 changed files
with
122 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
id: angular | ||
title: Angular | ||
sidebar_label: Angular | ||
--- | ||
|
||
## What | ||
|
||
Display the currently active Angular CLI version. | ||
|
||
## Sample Configuration | ||
|
||
```json | ||
{ | ||
"type": "angular", | ||
"style": "powerline", | ||
"powerline_symbol": "", | ||
"foreground": "#000000", | ||
"background": "#1976d2", | ||
"properties": { | ||
"prefix": "\uE753" | ||
} | ||
} | ||
``` | ||
|
||
## Properties | ||
|
||
- display_version: `boolean` - display the active version or not; useful if all you need is an icon indicating `ng` | ||
- display_mode: `string` - determines when the segment is displayed | ||
- `always`: the segment is always displayed | ||
- `files`: the segment is only displayed when `angular.json` file is present (default) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ module.exports = { | |
type: "category", | ||
label: "Segments", | ||
items: [ | ||
"angular", | ||
"aws", | ||
"az", | ||
"azfunc", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package main | ||
|
||
type angular struct { | ||
language *language | ||
} | ||
|
||
func (a *angular) string() string { | ||
return a.language.string() | ||
} | ||
|
||
func (a *angular) init(props *properties, env environmentInfo) { | ||
a.language = &language{ | ||
env: env, | ||
props: props, | ||
extensions: []string{"angular.json"}, | ||
commands: []*cmd{ | ||
{ | ||
executable: "ng", | ||
args: []string{"--version"}, | ||
regex: `Angular CLI: (?:(?P<version>((?P<major>[0-9]+).(?P<minor>[0-9]+).(?P<patch>[0-9]+))))`, | ||
}, | ||
}, | ||
versionURLTemplate: "[%s](https://github.com/angular/angular/releases/tag/%s.%s.%s)", | ||
} | ||
} | ||
|
||
func (a *angular) enabled() bool { | ||
return a.language.enabled() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestAngularCliVersionDisplayed(t *testing.T) { | ||
cases := []struct { | ||
Case string | ||
ExpectedString string | ||
Version string | ||
}{ | ||
{Case: "Angular 12.2.9", ExpectedString: "12.2.9", Version: "Angular CLI: 12.2.9"}, | ||
} | ||
|
||
for _, ta := range cases { | ||
params := &mockedLanguageParams{ | ||
cmd: "ng", | ||
versionParam: "--version", | ||
versionOutput: ta.Version, | ||
extension: "angular.json", | ||
} | ||
|
||
env, props := getMockedLanguageEnv(params) | ||
angular := &angular{} | ||
angular.init(props, env) | ||
assert.True(t, angular.enabled(), fmt.Sprintf("Failed in case: %s", ta.Case)) | ||
assert.Equal(t, ta.ExpectedString, angular.string(), fmt.Sprintf("Failed in case: %s", ta.Case)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters