Skip to content

Commit

Permalink
feat(get): support file:// for options.downloadUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushmanchhabra committed Mar 26, 2024
1 parent 1935800 commit 094567c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ Options
| flavor | `"normal" \| "sdk"` | `"normal"` | Runtime flavor |
| platform | `"linux" \| "osx" \| "win"` | | Host platform |
| arch | `"ia32" \| "x64" \| "arm64"` | | Host architecture |
| downloadUrl | `"https://dl.nwjs.io" \| "https://npm.taobao.org/mirrors/nwjs" \| https://npmmirror.com/mirrors/nwjs \| "https://github.com/corwin-of-amber/nw.js/releases/"` | `"https://dl.nwjs.io"` | Download server |
| downloadUrl | `"https://dl.nwjs.io" \| "https://npm.taobao.org/mirrors/nwjs" \| https://npmmirror.com/mirrors/nwjs \| "https://github.com/corwin-of-amber/nw.js/releases/"` | `"https://dl.nwjs.io"` | Download server. Supports file systems too (for example `file:///home/localghost/nwjs_mirror`) |
| manifestUrl | `"https://nwjs.io/versions" \| "https://raw.githubusercontent.com/nwutils/nw-builder/main/src/util/osx.arm.versions.json"` | `"https://nwjs.io/versions"` | Versions manifest |
| cacheDir | `string` | `"./cache"` | Directory to cache NW binaries |
| srcDir | `string` | `"./"` | File paths to application code |
Expand Down
7 changes: 7 additions & 0 deletions src/get/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ import util from "../util.js";
*/
async function get(options) {

const uri = new url.URL(options.downloadUrl);

/* Download server is the cached directory. */
if (uri.protocol === 'file:') {
options.cacheDir = path.resolve(decodeURIComponent(options.downloadUrl.slice('file://'.length)));
}

/**
* If `options.cacheDir` exists, then `true`. Otherwise, it is `false`.
*
Expand Down

0 comments on commit 094567c

Please sign in to comment.