npm-pkgbuild 7.4.2 → 7.4.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-pkgbuild",
3
- "version": "7.4.2",
3
+ "version": "7.4.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -11,7 +11,7 @@ import { ContentProvider } from "./content-provider.mjs";
11
11
  * @param {string} definitions.base base directory where to find the files
12
12
  */
13
13
  export class FileContentProvider extends ContentProvider {
14
- constructor(definitions) {
14
+ constructor(definitions, entryProperties) {
15
15
  super();
16
16
 
17
17
  if (typeof definitions === "string") {
@@ -24,6 +24,8 @@ export class FileContentProvider extends ContentProvider {
24
24
  this.definitions = { pattern: ["**/*"], ...definitions };
25
25
  this.definitions.pattern = asArray(this.definitions.pattern);
26
26
  }
27
+
28
+ this.entryProperties = entryProperties;
27
29
  }
28
30
 
29
31
  async *[Symbol.asyncIterator]() {
@@ -33,7 +35,9 @@ export class FileContentProvider extends ContentProvider {
33
35
  for (const name of await globby(definitions.pattern, {
34
36
  cwd: base
35
37
  })) {
36
- yield new FileSystemEntry(name, base);
38
+ const entry = new FileSystemEntry(name, base);
39
+ Object.assign(entry, this.entryProperties);
40
+ yield entry;
37
41
  }
38
42
  }
39
43
  }
@@ -57,17 +57,20 @@ program
57
57
  sources.push(
58
58
  ...[...options.content, ...options.meta]
59
59
  .filter(x => x)
60
- .map(source => [
61
- new FileContentProvider({
62
- base: source
63
- }),
64
- ""
65
- ])
60
+ .map(
61
+ source =>
62
+ new FileContentProvider({
63
+ base: source
64
+ })
65
+ )
66
66
  );
67
67
 
68
68
  const output = new outputFactory(properties);
69
69
 
70
- const fileName = await output.execute(aggregateFifo(sources.map(([c, d]) => c[Symbol.asyncIterator]() )), options);
70
+ const fileName = await output.execute(
71
+ aggregateFifo(sources.map(c => c[Symbol.asyncIterator]())),
72
+ options
73
+ );
71
74
 
72
75
  console.log(fileName);
73
76
  }
package/src/util.mjs CHANGED
@@ -63,16 +63,16 @@ export function extractFromPackage(pkg) {
63
63
  .forEach(([k, v]) => (properties[k] = v));
64
64
 
65
65
  if (pkgbuild.content) {
66
- sources = Object.entries(pkgbuild.content).map(([destination, value]) => [
67
- new FileContentProvider(value),
68
- destination
69
- ]);
66
+ sources = Object.entries(pkgbuild.content).map(
67
+ ([destination, value]) =>
68
+ new FileContentProvider(value, { destination })
69
+ );
70
70
  }
71
71
 
72
- Object.assign(dependencies,pkgbuild.depends)
72
+ Object.assign(dependencies, pkgbuild.depends);
73
73
  }
74
74
 
75
- return { properties, sources, dependencies};
75
+ return { properties, sources, dependencies };
76
76
  }
77
77
 
78
78
  /**
@@ -80,7 +80,7 @@ export function extractFromPackage(pkg) {
80
80
  * @param {AsyncIterator<ContentEntry>} source
81
81
  * @param {Transformer[]} transformers
82
82
  */
83
- export async function* transform(source, transformers=[], onlyMatching) {
83
+ export async function* transform(source, transformers = [], onlyMatching) {
84
84
  const usedTransformers = new Set();
85
85
 
86
86
  for await (let entry of source) {
@@ -89,13 +89,13 @@ export async function* transform(source, transformers=[], onlyMatching) {
89
89
  entry = await t.transform(entry);
90
90
  usedTransformers.add(t);
91
91
 
92
- if(onlyMatching) {
92
+ if (onlyMatching) {
93
93
  yield entry;
94
94
  }
95
95
  }
96
96
  }
97
97
 
98
- if(!onlyMatching) {
98
+ if (!onlyMatching) {
99
99
  yield entry;
100
100
  }
101
101
  }
@@ -118,7 +118,7 @@ export async function copyEntries(
118
118
  attributes = []
119
119
  ) {
120
120
  for await (let entry of source) {
121
- const destName = join(destinationDirectory, entry.name);
121
+ const destName = entry.destination === undefined ? join(destinationDirectory, entry.name) : join(destinationDirectory, entry.destination, entry.name);
122
122
  await mkdir(dirname(destName), { recursive: true });
123
123
 
124
124
  const options = { mode: entry.mode };