(value: JsonValue, sortExports: string[])
| 175 | } |
| 176 | |
| 177 | function orderExports(value: JsonValue, sortExports: string[]): JsonValue { |
| 178 | if (!value || typeof value !== 'object' || Array.isArray(value)) { |
| 179 | return value |
| 180 | } |
| 181 | |
| 182 | const object = value as JsonObject |
| 183 | const keys = Object.keys(object) |
| 184 | if (keys.some(key => sortExports.includes(key))) { |
| 185 | return orderObjectByKeys(object, sortExports) |
| 186 | } |
| 187 | |
| 188 | const result: JsonObject = {} |
| 189 | for (const key of keys.sort((left, right) => { |
| 190 | if (left === '.') { |
| 191 | return right === '.' ? 0 : -1 |
| 192 | } |
| 193 | if (right === '.') { |
| 194 | return 1 |
| 195 | } |
| 196 | return left < right ? -1 : left > right ? 1 : 0 |
| 197 | })) { |
| 198 | const child = object[key] |
| 199 | if (child && typeof child === 'object' && !Array.isArray(child)) { |
| 200 | result[key] = orderExports(child, sortExports) |
| 201 | continue |
| 202 | } |
| 203 | |
| 204 | result[key] = child |
| 205 | } |
| 206 | |
| 207 | return result |
| 208 | } |
| 209 | |
| 210 | function dependencyObject( |
| 211 | packageNames: string[] | undefined, |
no test coverage detected