repo-util 1.23.1 → 1.23.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repo-util",
3
- "version": "1.23.1",
3
+ "version": "1.23.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -129,6 +129,36 @@ function normalize(names) {
129
129
  return names.length === 0 ? ["*"] : names;
130
130
  }
131
131
 
132
+ function listAttributes(object, attributes, options) {
133
+ const values = {};
134
+ let maxKeyLength = 0;
135
+
136
+ for (const a of attributes) {
137
+ let value = object[a];
138
+ if (Array.isArray(value)) {
139
+ value = value.join(" ");
140
+ } else if (value instanceof Set) {
141
+ value = [...value].join(" ");
142
+ } else if (value === undefined) {
143
+ value = "";
144
+ }
145
+
146
+ if (a.length > maxKeyLength) {
147
+ maxKeyLength = a.length;
148
+ }
149
+
150
+ values[a] = value;
151
+ }
152
+
153
+ for (const [k, v] of Object.entries(values)) {
154
+ if (options.identifier) {
155
+ console.log(" ".repeat(maxKeyLength - k.length + 2) + k + `: ${v}`);
156
+ } else {
157
+ console.log(v);
158
+ }
159
+ }
160
+ }
161
+
132
162
  async function list(provider, names, options, slot, attributes, actions) {
133
163
  const json = [];
134
164
 
@@ -144,27 +174,10 @@ async function list(provider, names, options, slot, attributes, actions) {
144
174
  if (options.json) {
145
175
  json.push(object);
146
176
  } else {
147
- for (const a of attributes) {
148
- let value = object[a];
149
- if (Array.isArray(value)) {
150
- value = value.join(" ");
151
- } else if (value instanceof Set) {
152
- value = [...value].join(" ");
153
- } else if (value === undefined) {
154
- value = "";
155
- }
156
-
157
- if (options.identifier === false) {
158
- console.log(value);
159
- } else {
160
- console.log(
161
- attributes.indexOf(a) === 0
162
- ? object.fullName + ":"
163
- : " ".substring(a.length) + a + ":",
164
- value
165
- );
166
- }
177
+ if (options.identifier) {
178
+ console.log(`${object.fullName}:`);
167
179
  }
180
+ listAttributes(object, attributes, options);
168
181
  }
169
182
  }
170
183