Skip to content

Commit e3263a0

Browse files
committed
Rename hooks to events
1 parent a048646 commit e3263a0

24 files changed

+140
-1129
lines changed

.gometalinter.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"Enable": [
3+
"vet",
4+
"deadcode",
5+
"unconvert",
6+
"golint",
7+
"varcheck",
8+
"goconst",
9+
"gocyclo",
10+
"gotype"
11+
],
12+
"Exclude": [
13+
"exported const",
14+
"suspect or"
15+
]
16+
}

activestate.yaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ scripts: &scripts
6262
$scripts.build
6363
build/state --help
6464
commands: *scripts # temporary alias for backwards compatibility
65-
hooks:
65+
events: &events
6666
- name: ACTIVATE
6767
value: |
6868
$variables.ENV
@@ -75,4 +75,5 @@ hooks:
7575
if ! type "swagger" &> /dev/null; then
7676
echo "swagger was not found on your PATH, installing .."
7777
go get -u github.com/go-swagger/go-swagger/cmd/swagger
78-
fi
78+
fi
79+
hooks: *events # temporary alias for backwards compatibility

internal/locale/a_locale-packr.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/subshell/subshell.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ type SubShell interface {
7171
func Activate(wg *sync.WaitGroup) (SubShell, error) {
7272
logging.Debug("Activating Subshell")
7373

74-
// Why another check here? Because some things like hooks / run script don't take the virtualenv route,
74+
// Why another check here? Because some things like events / run script don't take the virtualenv route,
7575
// realistically this shouldn't really happen, but it's a useful failsafe for us
7676
activeProject := os.Getenv(constants.ActivatedStateEnvVarName)
7777
if activeProject != "" {
@@ -99,9 +99,9 @@ func getRcFile(v SubShell) (*os.File, error) {
9999
prj := project.Get()
100100

101101
userScripts := ""
102-
for _, hook := range prj.Hooks() {
103-
if hook.Name() == "ACTIVATE" {
104-
userScripts = userScripts + "\n" + hook.Value()
102+
for _, event := range prj.Events() {
103+
if event.Name() == "ACTIVATE" {
104+
userScripts = userScripts + "\n" + event.Value()
105105
}
106106
}
107107

internal/variables/variables.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ type ExpanderFunc func(name string, project *projectfile.Project) (string, *fail
9393
var expanderRegistry = map[string]ExpanderFunc{
9494
"platform": PlatformExpander,
9595
"variables": VariableExpander,
96-
"hooks": HookExpander,
96+
"events": EventExpander,
9797
"scripts": ScriptExpander,
9898
}
9999

@@ -154,12 +154,12 @@ func VariableExpander(name string, project *projectfile.Project) (string, *failu
154154
return value, nil
155155
}
156156

157-
// HookExpander expands hooks defined in the project-file.
158-
func HookExpander(name string, project *projectfile.Project) (string, *failures.Failure) {
157+
// EventExpander expands events defined in the project-file.
158+
func EventExpander(name string, project *projectfile.Project) (string, *failures.Failure) {
159159
var value string
160-
for _, hook := range project.Hooks {
161-
if hook.Name == name && !constraints.IsConstrained(hook.Constraints) {
162-
value = hook.Value
160+
for _, event := range project.Events {
161+
if event.Name == name && !constraints.IsConstrained(event.Constraints) {
162+
value = event.Value
163163
break
164164
}
165165
}

internal/variables/variables_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ variables:
3737
platform: Windows
3838
- name: UPPERCASE
3939
value: foo
40-
hooks:
40+
events:
4141
- name: pre
4242
value: echo 'Hello $variables.foo!'
4343
- name: post
@@ -69,23 +69,23 @@ func TestExpandProjectPlatformOs(t *testing.T) {
6969
}
7070
}
7171

72-
func TestExpandProjectHook(t *testing.T) {
72+
func TestExpandProjectEvent(t *testing.T) {
7373
project := loadProject(t)
7474

75-
expanded := ExpandFromProject("$hooks.pre", project)
75+
expanded := ExpandFromProject("$events.pre", project)
7676
assert.NoError(t, Failure().ToError(), "Ran without failure")
7777
assert.Equal(t, "echo 'Hello bar!'", expanded, "Expanded simple variable")
7878
}
7979

80-
func TestExpandProjectHookWithConstraints(t *testing.T) {
80+
func TestExpandProjectEventWithConstraints(t *testing.T) {
8181
project := loadProject(t)
8282

8383
if runtime.GOOS == "linux" {
84-
expanded := ExpandFromProject("$hooks.post", project)
84+
expanded := ExpandFromProject("$events.post", project)
8585
assert.NoError(t, Failure().ToError(), "Ran without failure")
8686
assert.Equal(t, "echo 'Hello baz!'", expanded, "Expanded platform-specific variable")
8787
} else if runtime.GOOS == "windows" {
88-
expanded := ExpandFromProject("$hooks.post", project)
88+
expanded := ExpandFromProject("$events.post", project)
8989
assert.NoError(t, Failure().ToError(), "Ran without failure")
9090
assert.Equal(t, "echo 'Hello quux!'", expanded, "Expanded platform-specific variable")
9191
}

locale/en-us.yaml

+13-57
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,16 @@ state_description:
44
other: The ActiveState CLI allows you to easily switch between your ActiveState environments
55
activate_project:
66
other: activate a project
7-
hook_description:
8-
other: Manage Project Hooks
9-
hook_add_description:
10-
other:
11-
>
12-
add script to run on hook trigger
13-
hook_remove_description:
14-
other:
15-
>
16-
remove script for hook trigger
17-
hook_header_id:
7+
events_description:
8+
other: Manage Project Events
9+
events_header_id:
1810
other: ID
19-
hook_header_hook:
20-
other: HOOK
21-
hook_header_command:
22-
other: COMMAND
23-
hook_listing_hooks:
24-
other: Listing configured hooks
11+
events_header_event:
12+
other: Event
13+
events_header_value:
14+
other: Value
15+
event_listing:
16+
other: Listing configured events
2517
usage_tpl:
2618
other: "
2719
Usage:
@@ -119,52 +111,16 @@ error_could_not_activate_venv:
119111
other: Could not activate the virtual environment
120112
warning_language_not_yet_supported:
121113
other: "Warning: Your project configuration includes {{.Language}}, but this language is not yet supported"
122-
error_could_not_run_hooks:
123-
other: Could not run hooks
124-
info_running_hook:
125-
other: "Running hook: {{.Name}}"
126-
hook_add_cannot_add_hook:
127-
other: "Cannot add hook '{{.Hook}} {{.Script}}'"
128-
hook_add_cannot_add_existing_hook:
129-
other: "Identical hook already configured"
130-
hook_remove_multiple_hooks:
131-
other: "More than one configured hook for name given. Use ID instead."
132-
hook_remove_cannot_remove:
133-
other: "Cannot remove hook"
134114
error_missing_arg:
135115
other: "Argument missing: {{.Name}}"
136-
arg_hook_add_hook:
137-
other: HOOK
138-
arg_hook_add_hook_description:
139-
other: The hook that will be listened to
140-
error_hook_add_invalid_hook:
141-
other: "Invalid hook given: {{.V0}}"
142-
arg_hook_add_script:
143-
other: SCRIPT
144-
arg_hook_add_script_description:
145-
other: The script that will be run
146-
arg_hook_remove_identifier:
147-
other: IDENTIFIER
148-
arg_hook_remove_identifier_description:
149-
other: Identifies what hook to remove, can be a hash or a hook name
150-
prompt_choose_hook:
151-
other: Which hook do you wish to remove?
152116
err_no_projectfile:
153117
other: No activestate.yaml file exists in the current working directory
154118
err_parse_project:
155119
other: "Could not parse project file. For more info refer to the error log"
156-
err_hook_cannot_list:
157-
other: Cannot list hooks
158-
err_hook_cannot_find:
159-
other: Cannot find hooks matching your query
160-
prompt_hook_choose_remove:
161-
other: Which hook would you like to remove?
162-
prompt_hook_option:
163-
other: "{{.Hook.Name}}: `{{.Script}}` ({{.Constraints}}{{.Hash}})"
164120
err_invalid_input:
165121
other: Invalid input received
166-
hook_removed:
167-
other: "Hook removed: {{.Hook.Name}} ({{.Hash}})"
122+
events_empty:
123+
other: No events found for the current environment
168124
err_no_update_info:
169125
other: Cannot retrieve update information
170126
no_update_available:
@@ -455,8 +411,8 @@ print_state_show_url:
455411
other: URL
456412
print_state_show_platforms:
457413
other: Platforms
458-
print_state_show_hooks:
459-
other: Hooks that will run
414+
print_state_show_events:
415+
other: Events that will run
460416
print_state_show_scripts:
461417
other: Scripts
462418
print_state_show_languages:

pkg/cmdlets/hooks/hooks.go

-169
This file was deleted.

0 commit comments

Comments
 (0)