From 601911fbb374fd01b07fa138718b0d7d2751fc51 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Sat, 27 Apr 2024 21:38:49 +0530 Subject: [PATCH] fix: set default cache dir by using __dirname (#158) * Add missing srcDir option Fixes: #157 --- src/parse.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/parse.js b/src/parse.js index 0b54e4e..3c5263c 100644 --- a/src/parse.js +++ b/src/parse.js @@ -15,6 +15,7 @@ import util from '../src/util.js'; * @property {"ia32" | "x64" | "arm64"} arch Target arch * @property {string} downloadUrl Download server. * @property {string} cacheDir Cache directory + * @property {string} srcDir Source directory * @property {boolean} cache If false, remove cache and redownload. * @property {boolean} ffmpeg If true, ffmpeg is not downloaded. * @property {false | "gyp"} nativeAddon Rebuild native modules @@ -67,7 +68,8 @@ export default async function parse(options) { options.platform = options.platform || util.PLATFORM_KV[process.env.npm_config_nwjs_platform || process.env.NWJS_PLATFORM || process.platform]; options.arch = options.arch || util.ARCH_KV[process.env.npm_config_nwjs_process_arch || process.env.NWJS_ARCH || process.arch]; options.downloadUrl = options.downloadUrl || process.env.npm_config_nwjs_urlbase || process.env.NWJS_URLBASE || 'https://dl.nwjs.io'; - options.cacheDir = options.npm_config_nwjs_urlbase || process.env.npm_config_nwjs_cache_dir || process.env.NWJS_CACHE_DIR || path.resolve('.', 'node_modules', 'nw'); + options.cacheDir = options.npm_config_nwjs_urlbase || process.env.npm_config_nwjs_cache_dir || process.env.NWJS_CACHE_DIR || path.resolve(__dirname, '..'); + options.srcDir = options.srcDir || process.cwd(); options.cache = options.cache || process.env.npm_config_nwjs_cache || process.env.NWJS_CACHE || true; options.ffmpeg = options.ffmpeg || process.env.npm_config_nwjs_ffmpeg || process.env.NWJS_FFMPEG || false; options.nativeAddon = options.nativeAddon || process.env.npm_config_nwjs_native_addon || process.env.NWJS_NATIVE_ADDON || false;