@xhmikosr/bin-wrapper 14.2.5 → 14.3.0

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.
Files changed (3) hide show
  1. package/index.js +12 -5
  2. package/package.json +1 -1
  3. package/readme.md +4 -0
package/index.js CHANGED
@@ -107,6 +107,15 @@ export default class BinWrapper {
107
107
  return path.join(this.dest(), this.use());
108
108
  }
109
109
 
110
+ /**
111
+ * Get the source URLs matching the current OS and arch
112
+ *
113
+ * @returns {string[]}
114
+ */
115
+ resolvedUrls() {
116
+ return osFilterObject(this.src() || []).map(file => file.url);
117
+ }
118
+
110
119
  /**
111
120
  * Check for the binary and download it if missing, then optionally verify it works.
112
121
  *
@@ -166,14 +175,12 @@ export default class BinWrapper {
166
175
  * @api private
167
176
  */
168
177
  async download() {
169
- const files = osFilterObject(this.src() || []);
178
+ const urls = this.resolvedUrls();
170
179
 
171
- if (files.length === 0) {
180
+ if (urls.length === 0) {
172
181
  throw new Error('No binary found matching your system. It\'s probably not supported.');
173
182
  }
174
183
 
175
- const urls = files.map(file => file.url);
176
-
177
184
  const results = await Promise.all(urls.map(url =>
178
185
  downloader(url, this.dest(), {
179
186
  extract: true,
@@ -187,7 +194,7 @@ export default class BinWrapper {
187
194
  return item.map(file => file.path);
188
195
  }
189
196
 
190
- const parsedUrl = new URL(files[index].url);
197
+ const parsedUrl = new URL(urls[index]);
191
198
 
192
199
  return path.parse(parsedUrl.pathname).base;
193
200
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xhmikosr/bin-wrapper",
3
- "version": "14.2.5",
3
+ "version": "14.3.0",
4
4
  "description": "Binary wrapper that makes your programs seamlessly available as local dependencies",
5
5
  "license": "MIT",
6
6
  "repository": {
package/readme.md CHANGED
@@ -105,6 +105,10 @@ Define which file to use as the binary.
105
105
 
106
106
  Returns the full path to your binary.
107
107
 
108
+ ### .resolvedUrls()
109
+
110
+ Returns an array of the source URLs matching the current OS and arch.
111
+
108
112
  ### .version(range)
109
113
 
110
114
  #### range