home-config/fish/functions/_tide_item_pulumi.fish

1d58393e99753ce529914df7eb4b104ad6c2061b · 733 B · 19 lines raw

1 function _tide_item_pulumi
2 if path filter $_tide_parent_dirs/Pulumi.yaml | read -l yaml_path
3 if command -q sha1sum
4 echo -n "$yaml_path" | sha1sum | string match -qr "(?<path_hash>.{40})"
5 else if command -q shasum
6 echo -n "$yaml_path" | shasum | string match -qr "(?<path_hash>.{40})"
7 else
8 return
9 end
10
11 string match -qr 'name: *(?<project_name>.*)' <$yaml_path
12 set -l workspace_file "$HOME/.pulumi/workspaces/$project_name-$path_hash-workspace.json"
13
14 if test -e $workspace_file
15 string match -qr '"stack": *"(?<stack>.*)"' <$workspace_file
16 _tide_print_item pulumi $tide_pulumi_icon' ' $stack
17 end
18 end
19 end