diff --git a/README.md b/README.md index a0316a076..e61dd27dd 100644 --- a/README.md +++ b/README.md @@ -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 | diff --git a/src/get/index.js b/src/get/index.js index a4638002c..30bfbaafb 100644 --- a/src/get/index.js +++ b/src/get/index.js @@ -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`. *