nw-builder 4.3.4 → 4.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/get.js +13 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nw-builder",
3
- "version": "4.3.4",
3
+ "version": "4.3.5",
4
4
  "description": "Build NW.js desktop applications for MacOS, Windows and Linux.",
5
5
  "keywords": [
6
6
  "NW.js",
package/src/get.js CHANGED
@@ -4,6 +4,7 @@ import { mkdir, readdir, rm, rmdir } from "node:fs/promises";
4
4
  import { get as getRequest } from "node:https";
5
5
  import { resolve } from "node:path";
6
6
  import { arch as ARCH, platform as PLATFORM } from "node:process";
7
+ import { log } from "./log.js";
7
8
 
8
9
  import progress from "cli-progress";
9
10
  import compressing from "compressing";
@@ -84,6 +85,7 @@ export async function get({
84
85
  cache = true,
85
86
  ffmpeg = false,
86
87
  }) {
88
+ log.debug(`Start getting binaries`);
87
89
  let nwCached = true;
88
90
  const nwDir = resolve(
89
91
  cacheDir,
@@ -117,27 +119,32 @@ export async function get({
117
119
 
118
120
  // If options.cache is false, remove cache.
119
121
  if (cache === false) {
122
+ log.debug(`Removing existing binaries`);
120
123
  rmdir(nwDir, { recursive: true, force: true });
121
124
  }
122
125
 
123
126
  // Check if cache exists.
124
127
  try {
125
128
  await readdir(nwDir);
129
+ log.debug(`Found existing binaries`);
126
130
  } catch (error) {
131
+ log.debug(`No existing binaries`);
127
132
  nwCached = false;
128
133
  }
129
134
 
130
135
  // If not cached, then download.
131
136
  if (nwCached === false) {
137
+ log.debug(`Downloading binaries`);
132
138
  await mkdir(nwDir, { recursive: true });
133
139
 
134
140
  const stream = createWriteStream(out);
135
141
  const request = new Promise((resolve, reject) => {
136
142
  getRequest(url, (response) => {
143
+ log.debug(`Response from ${url}`);
137
144
  // For GitHub releases and mirrors, we need to follow the redirect.
138
145
  if (
139
146
  downloadUrl ===
140
- "https://github.com/nwjs-ffmpeg-prebuilt/nwjs-ffmpeg-prebuilt/releases/download" ||
147
+ "https://github.com/nwjs-ffmpeg-prebuilt/nwjs-ffmpeg-prebuilt/releases/download" ||
141
148
  downloadUrl === "https://npm.taobao.org/mirrors/nwjs" ||
142
149
  downloadUrl === "https://npmmirror.com/mirrors/nwjs"
143
150
  ) {
@@ -145,6 +152,7 @@ export async function get({
145
152
  }
146
153
 
147
154
  getRequest(url, (response) => {
155
+ log.debug(`Response from ${url}`);
148
156
  let chunks = 0;
149
157
  bar.start(Number(response.headers["content-length"]), 0);
150
158
  response.on("data", async (chunk) => {
@@ -158,6 +166,7 @@ export async function get({
158
166
  });
159
167
 
160
168
  response.on("end", () => {
169
+ log.debug(`Binary fully downloaded`);
161
170
  bar.stop();
162
171
  if (platform === "linux") {
163
172
  compressing.tgz
@@ -180,7 +189,8 @@ export async function get({
180
189
  });
181
190
 
182
191
  // Remove compressed file after download and decompress.
183
- request.then(async () => {
192
+ return request.then(async () => {
193
+ log.debug(`Binary decompressed starting removal`);
184
194
  await rm(resolve(cacheDir, "ffmpeg.zip"), {
185
195
  recursive: true,
186
196
  force: true,
@@ -190,6 +200,7 @@ export async function get({
190
200
  resolve(cacheDir, `nw.${platform === "linux" ? "tgz" : "zip"}`),
191
201
  { recursive: true, force: true },
192
202
  );
203
+ log.debug(`Binary zip removed`);
193
204
  });
194
205
  }
195
206
  }