Skip to content

Commit 1a6fa68

Browse files
committed
Sort glob, 4.8.8
1 parent 08c2654 commit 1a6fa68

File tree

2 files changed

+41
-31
lines changed

2 files changed

+41
-31
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cogs",
3-
"version": "4.8.7",
3+
"version": "4.8.8",
44
"type": "module",
55
"author": "Casey Foster <c@sey.me>",
66
"description": "The fast file transform pipeline.",

src/build-config.js

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -54,38 +54,48 @@ const saveBuild = async ({
5454
);
5555
};
5656

57+
const glob = async pattern =>
58+
(await Array.fromAsync(fs.glob(pattern, { withFileTypes: true })))
59+
.flatMap(dirent =>
60+
dirent.isDirectory()
61+
? []
62+
: npath.relative('.', npath.join(dirent.parentPath, dirent.name))
63+
)
64+
.sort();
65+
5766
const saveBuilds = async ({ env, manifest, onError, onResult }) =>
5867
await Promise.all(
59-
_.map(env.builds, async (target, pattern) => {
60-
const paths = (
61-
await Array.fromAsync(fs.glob(pattern, { withFileTypes: true }))
62-
).flatMap(dirent =>
63-
dirent.isDirectory()
64-
? []
65-
: npath.relative('.', npath.join(dirent.parentPath, dirent.name))
66-
);
67-
return await Promise.all(
68-
paths.map(async path => {
69-
try {
70-
const builds = flattenBuilds(
71-
await getBuild({
72-
env,
73-
maxChunkSize: target.maxChunkSize,
74-
path,
75-
transformers: target.transformers
76-
})
77-
);
78-
await Promise.all(
79-
_.map(builds, async build => {
80-
await saveBuild({ build, manifest, onError, onResult, target });
81-
})
82-
);
83-
} catch (error) {
84-
await onError({ error, sourcePath: path });
85-
}
86-
})
87-
);
88-
})
68+
_.map(
69+
env.builds,
70+
async (target, pattern) =>
71+
await Promise.all(
72+
(await glob(pattern)).map(async path => {
73+
try {
74+
const builds = flattenBuilds(
75+
await getBuild({
76+
env,
77+
maxChunkSize: target.maxChunkSize,
78+
path,
79+
transformers: target.transformers
80+
})
81+
);
82+
await Promise.all(
83+
_.map(builds, async build => {
84+
await saveBuild({
85+
build,
86+
manifest,
87+
onError,
88+
onResult,
89+
target
90+
});
91+
})
92+
);
93+
} catch (error) {
94+
await onError({ error, sourcePath: path });
95+
}
96+
})
97+
)
98+
)
8999
);
90100

91101
const buildConfig = async ({ built, config, onResult, started }) => {

0 commit comments

Comments
 (0)