Skip to content

Commit

Permalink
chore(util): create function to convert valid boolean types in string…
Browse files Browse the repository at this point in the history
… to boolean
  • Loading branch information
ayushmanchhabra committed Oct 31, 2024
1 parent c0de611 commit 496b566
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"test:cov": "vitest --coverage.enabled true",
"demo:bld": "node ./tests/fixtures/demo.js",
"demo:exe": "./tests/fixtures/out/nwapp.app/Contents/MacOS/nwapp",
"demo:cli": "nwbuild --mode=run --glob=false --cacheDir=./node_modules/nw ./tests/fixtures/app"
"demo:cli": "nwbuild --mode=run --version=0.92.0 --flavor=sdk --glob=false --cacheDir=./node_modules/nw ./tests/fixtures/app"
},
"devDependencies": {
"@eslint/js": "^9.12.0",
Expand Down
31 changes: 25 additions & 6 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,24 @@ async function getNodeManifest({
return manifest;
}

/**
*
* @param {any} option

Check warning on line 166 in src/util.js

View workflow job for this annotation

GitHub Actions / tests (macos-14)

Missing JSDoc @param "option" description

Check warning on line 166 in src/util.js

View workflow job for this annotation

GitHub Actions / tests (ubuntu-22.04)

Missing JSDoc @param "option" description

Check warning on line 166 in src/util.js

View workflow job for this annotation

GitHub Actions / tests (windows-2022)

Missing JSDoc @param "option" description
* @returns {any}

Check warning on line 167 in src/util.js

View workflow job for this annotation

GitHub Actions / tests (macos-14)

Missing JSDoc @returns description

Check warning on line 167 in src/util.js

View workflow job for this annotation

GitHub Actions / tests (ubuntu-22.04)

Missing JSDoc @returns description

Check warning on line 167 in src/util.js

View workflow job for this annotation

GitHub Actions / tests (windows-2022)

Missing JSDoc @returns description
*/
function str2Bool (option) {
console.log('debugg', option);
if (typeof option === 'string') {
if (option === 'true') {
return true;
} else if (option === 'false') {
return false;
}
} else {
return option;
}
}

/**
* Parse options.
* @param {import("../../index.js").Options} options Options
Expand All @@ -178,27 +196,28 @@ export const parse = async (options, pkg) => {
options.downloadUrl = options.downloadUrl ?? 'https://dl.nwjs.io';
options.manifestUrl = options.manifestUrl ?? 'https://nwjs.io/versions';
options.cacheDir = options.cacheDir ?? './cache';
options.cache = options.cache ?? true;
options.ffmpeg = options.ffmpeg ?? false;
options.cache = str2Bool(options.cache ?? true);
options.ffmpeg = str2Bool(options.ffmpeg ?? false);
options.logLevel = options.logLevel ?? 'info';

if (options.mode === 'get') {
return { ...options };
}

options.argv = options.argv ?? [];
options.glob = options.glob ?? true;
options.glob = str2Bool(options.glob) ?? true;
console.log('weee', str2Bool(options.glob));
options.srcDir = options.srcDir ?? (options.glob ? './*' : '.');

if (options.mode === 'run') {
return { ...options };
}

options.outDir = path.resolve(options.outDir ?? './out');
options.zip = options.zip ?? false;
options.zip = str2Bool(options.zip) ?? false;

options.managedManifest = options.managedManifest ?? false;
options.nativeAddon = options.nativeAddon ?? false;
options.managedManifest = str2Bool(options.managedManifest) ?? false;
options.nativeAddon = str2Bool(options.nativeAddon) ?? false;

options.app = options.app ?? {};
options.app.name = options.app.name ?? pkg.name;
Expand Down

0 comments on commit 496b566

Please sign in to comment.