@@ -80,54 +80,55 @@ import { log } from "./log.js";
8080const nwbuild = async ( options ) => {
8181 let nwDir = "" ;
8282 let cached ;
83+ let nwCached ;
8384 let built ;
8485 let releaseInfo = { } ;
8586
8687 notify ( ) ;
8788
8889 try {
89-
9090 const { opts, files, nwPkg } = await getOptions ( options ) ;
9191 options = opts ;
9292
93- // Parse options, set required values to undefined and flags with default values unless specified by user
93+ // Parse options
9494 options = await parse ( options , nwPkg ) ;
9595
96- // Validate options.version here
97- // We need to do this to get the version specific release info
96+ // Create cacheDir if it does not exist
97+ cached = await isCached ( options . cacheDir ) ;
98+ if ( cached === false ) {
99+ await mkdir ( options . cacheDir , { recursive : true } ) ;
100+ }
101+
102+ // Create outDir if it does not exist
103+ built = await isCached ( options . outDir ) ;
104+ if ( built === false ) {
105+ await mkdir ( options . outDir , { recursive : true } ) ;
106+ }
107+
108+ // Validate options.version to get the version specific release info
98109 releaseInfo = await getReleaseInfo (
99110 options . version ,
100111 options . cacheDir ,
101112 options . manifestUrl ,
102113 ) ;
103- options . version = releaseInfo . version ;
114+ // Remove leading "v" from version string
115+ options . version = releaseInfo . version . slice ( 1 ) ;
104116
105- validate ( options , releaseInfo ) ;
117+ await validate ( options , releaseInfo ) ;
106118
107119 // Variable to store nwDir file path
108120 nwDir = `${ options . cacheDir } /nwjs${
109121 options . flavor === "sdk" ? "-sdk" : ""
110122 } -v${ options . version } -${ options . platform } -${ options . arch } `;
111123
112- // Create cacheDir if it does not exist
113- cached = await isCached ( nwDir ) ;
114- if ( cached === false ) {
115- await mkdir ( nwDir , { recursive : true } ) ;
116- }
117-
118- // Create outDir if it does not exist
119- built = await isCached ( options . outDir ) ;
120- if ( built === false ) {
121- await mkdir ( options . outDir , { recursive : true } ) ;
122- }
123-
124+ nwCached = await isCached ( nwDir ) ;
124125 // Remove cached NW binary
125- if ( options . cache === false && cached === true ) {
126+ if ( options . cache === false && nwCached === true ) {
126127 log . debug ( "Remove cached NW binary" ) ;
127128 await rm ( nwDir , { force : true , recursive : true } ) ;
128129 }
129130 // Download relevant NW.js binaries
130- if ( cached === false ) {
131+ if ( nwCached === false ) {
131132 log . debug ( "Download relevant NW.js binaries" ) ;
132133 await download (
133134 options . version ,
0 commit comments