Skip to content

Commit

Permalink
feat(findpath): get file path to NW.js directory
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushmanchhabra committed Jun 15, 2024
1 parent 137ed6b commit 5b37b6d
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,28 @@ const EXE_NAME = {

/**
* Get the platform dependant path of the NW.js or ChromeDriver binary.
*
* @param {'nwjs' | 'chromedriver'} executable Path to NW.js or Chromedriver executable.
*
* @param {'nwjs' | 'chromedriver' | 'all'} Path to NW.js or Chromedriver executable.
* @return {Promise<string>}
*/
async function findpath(executable = 'nwjs', options = {}) {
options = await parse(options);
const nwDir = path.resolve(__dirname, '..', `nwjs${options.flavor === "sdk" ? "-sdk" : ""}-v${options.version}-${options.platform}-${options.arch}`);

/**
* File path to executable.
*
*
* @type {string}
*/
let binPath = '';

/**
* Get the platform dependant path of the NW.js directory containing everything.
*/
function findDir() {
binPath = nwDir;
}

/**
* Get the platform dependant path of the NW.js binary.
*/
Expand All @@ -76,6 +83,8 @@ async function findpath(executable = 'nwjs', options = {}) {
findNwjs();
} else if (executable === 'chromedriver') {
findChromeDriver();
} else if (executable === 'all') {
findDir();
} else {
console.error(`[ ERROR ] Expected nwjs or chromedriver, got ${executable}.`);
}
Expand Down

0 comments on commit 5b37b6d

Please sign in to comment.