Skip to content

Commit

Permalink
fix(parse): detect sdk build flavor (#183)
Browse files Browse the repository at this point in the history
Fixes: #181
  • Loading branch information
ayushmanchhabra authored Jun 21, 2024
1 parent 8a417f4 commit b4dbb64
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 23 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nw",
"version": "0.88.0-3",
"version": "0.88.0",
"description": "An installer for nw.js",
"repository": {
"type": "git",
Expand Down
23 changes: 3 additions & 20 deletions src/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import util from '../src/util.js';

/**
* Parse options.
*
* @param {ParseOptions} options
*
* @param {ParseOptions} options
* @return {Promise<ParseOptions>}
*/
export default async function parse(options) {
Expand All @@ -45,27 +45,10 @@ export default async function parse(options) {
parsedVersion.minor,
parsedVersion.patch
].join('.');

options.flavor = options.flavor || process.env.npm_config_nwjs_build_type || process.env.NWJS_BUILD_TYPE || 'normal';

/* Check if version is a prelease. */
if (typeof parsedVersion?.prerelease?.[0] === 'string') {
let prerelease = parsedVersion.prerelease[0].split('-');
if (prerelease.length > 1) {
prerelease = prerelease.slice(0, -1);
}
options.version = [options.version, ...prerelease].join('-');
}

/* Check build flavor and slice that off the `version`. */
if (options.version.endsWith('-sdk')) {
options.version = options.version.slice(0, -4);
options.flavor = 'sdk';
} else if (options.version.endsWith('sdk')) {
options.version = version.slice(0, -3);
if (parsedVersion?.prerelease[0]?.endsWith('sdk')) {
options.flavor = 'sdk';
}

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';
Expand Down

0 comments on commit b4dbb64

Please sign in to comment.