-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(util): create function to convert valid boolean types in string…
… to boolean
- Loading branch information
1 parent
c0de611
commit 496b566
Showing
2 changed files
with
26 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,6 +161,24 @@ async function getNodeManifest({ | |
return manifest; | ||
} | ||
|
||
/** | ||
* | ||
* @param {any} option | ||
Check warning on line 166 in src/util.js GitHub Actions / tests (macos-14)
Check warning on line 166 in src/util.js GitHub Actions / tests (ubuntu-22.04)
Check warning on line 166 in src/util.js GitHub Actions / tests (windows-2022)
|
||
* @returns {any} | ||
Check warning on line 167 in src/util.js GitHub Actions / tests (macos-14)
Check warning on line 167 in src/util.js GitHub Actions / tests (ubuntu-22.04)
Check warning on line 167 in src/util.js GitHub Actions / tests (windows-2022)
|
||
*/ | ||
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 | ||
|
@@ -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; | ||
|