npm-pkgbuild 7.11.4 → 7.11.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/output/pkg.mjs +30 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-pkgbuild",
3
- "version": "7.11.4",
3
+ "version": "7.11.5",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -1,14 +1,17 @@
1
- import { join } from "path";
2
- import { cp } from "fs/promises";
1
+ import { join, dirname } from "path";
2
+ import { createReadStream, createWriteStream } from "fs";
3
+ import { mkdir } from "fs/promises";
4
+ import { pipeline } from "stream/promises";
3
5
  import { execa } from "execa";
4
6
  import { EmptyContentEntry, ReadableStreamContentEntry } from "content-entry";
7
+ import { iterableStringInterceptor } from "iterable-string-interceptor";
5
8
  import {
6
9
  keyValueTransformer,
7
10
  equalSeparatedKeyValuePairOptions
8
11
  } from "key-value-transformer";
9
12
  import { Packager } from "./packager.mjs";
10
13
  import { copyEntries, transform, fieldProvider } from "../util.mjs";
11
- import { quote } from "../util.mjs";
14
+ import { quote, utf8StreamOptions } from "../util.mjs";
12
15
 
13
16
  /**
14
17
  * @type KeyValueTransformOptions
@@ -52,7 +55,7 @@ export class PKG extends Packager {
52
55
  async execute(sources, transformer, options, expander) {
53
56
  const properties = this.properties;
54
57
 
55
- if(properties.source) {
58
+ if (properties.source) {
56
59
  properties.md5sums = ["SKIP"];
57
60
  }
58
61
 
@@ -90,6 +93,27 @@ package() {
90
93
  });
91
94
 
92
95
  if (properties.hooks) {
96
+ async function* transformer(expression, remainder, source, cb) {
97
+ const value = properties[expression];
98
+ yield value === undefined ? "" : value;
99
+ }
100
+
101
+ const destination = join(staging, properties.hooks);
102
+
103
+ await mkdir(dirname(destination), { recursive: true });
104
+
105
+ await pipeline(
106
+ iterableStringInterceptor(
107
+ createReadStream(
108
+ join(options.pkgdir, properties.hooks),
109
+ utf8StreamOptions
110
+ ),
111
+ transformer
112
+ ),
113
+ createWriteStream(destination, utf8StreamOptions)
114
+ );
115
+
116
+ /*
93
117
  await cp(
94
118
  join(options.pkgdir, properties.hooks),
95
119
  join(staging, properties.hooks),
@@ -97,6 +121,7 @@ package() {
97
121
  preserveTimestamps: true
98
122
  }
99
123
  );
124
+ */
100
125
  }
101
126
 
102
127
  await copyEntries(transform(sources, transformer, true), staging, expander);
@@ -125,7 +150,7 @@ package() {
125
150
  const fields = {
126
151
  pkgname: { alias: "name", type: "string[]", mandatory: true },
127
152
  pkgver: { alias: "version", type: "string", mandatory: true },
128
- pkgrel: { alias: "release", type: "integer", default: 0, mandatory: true },
153
+ pkgrel: { alias: "release", type: "integer", default: 1, mandatory: true },
129
154
  epoch: { type: "integer", default: 0 },
130
155
  pkgdesc: { alias: "description", type: "string", mandatory: true },
131
156
  url: { alias: "homepage", type: "string" },