npm-pkgbuild 18.2.5 → 18.2.6

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/util.mjs +31 -29
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-pkgbuild",
3
- "version": "18.2.5",
3
+ "version": "18.2.6",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": false
package/src/util.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { join, dirname } from "node:path";
2
2
  import { mkdir } from "node:fs/promises";
3
3
  import { pipeline } from "node:stream/promises";
4
- import { Readable} from "node:stream";
4
+ import { Readable } from "node:stream";
5
5
 
6
6
  import { createWriteStream } from "node:fs";
7
7
  import { ContentEntry } from "content-entry";
@@ -209,35 +209,37 @@ export async function* copyEntries(
209
209
  expander = v => v
210
210
  ) {
211
211
  for await (const entry of source) {
212
- // @ts-ignore
213
- const d = entry.destination;
214
-
215
- const name = expander(
216
- d === undefined
217
- ? entry.name
218
- : d.isCollection || d.endsWith("/")
219
- ? join(d, entry.name)
220
- : d
221
- ).replace(/^\//, "");
222
-
223
- // @ts-ignore
224
- entry.destination = name;
225
- const destination = join(destinationDirectory, name);
212
+ if (entry) {
213
+ // @ts-ignore
214
+ const d = entry.destination;
215
+
216
+ const name = expander(
217
+ d === undefined
218
+ ? entry.name
219
+ : d.isCollection || d.endsWith("/")
220
+ ? join(d, entry.name)
221
+ : d
222
+ ).replace(/^\//, "");
223
+
224
+ // @ts-ignore
225
+ entry.destination = name;
226
+ const destination = join(destinationDirectory, name);
227
+
228
+ if (entry.isCollection) {
229
+ await mkdir(destination, { recursive: true, mode: await entry.mode });
230
+ } else {
231
+ await mkdir(dirname(destination), { recursive: true });
232
+
233
+ await pipeline(
234
+ Readable.fromWeb(await entry.stream),
235
+ createWriteStream(
236
+ destination,
237
+ entry.mode ? { mode: await entry.mode } : undefined
238
+ )
239
+ );
240
+ }
226
241
 
227
- if (entry.isCollection) {
228
- await mkdir(destination, { recursive: true, mode: await entry.mode });
229
- } else {
230
- await mkdir(dirname(destination), { recursive: true });
231
-
232
- await pipeline(
233
- Readable.fromWeb(await entry.stream),
234
- createWriteStream(
235
- destination,
236
- entry.mode ? { mode: await entry.mode } : undefined
237
- )
238
- );
242
+ yield entry;
239
243
  }
240
-
241
- yield entry;
242
244
  }
243
245
  }