Skip to content

Commit f3e620c

Browse files
committed
Drop needless packages
1 parent c03546d commit f3e620c

File tree

6 files changed

+29
-20
lines changed

6 files changed

+29
-20
lines changed

package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cogs",
3-
"version": "4.8.5",
3+
"version": "4.8.6",
44
"type": "module",
55
"author": "Casey Foster <c@sey.me>",
66
"description": "The fast file transform pipeline.",
@@ -19,10 +19,7 @@
1919
},
2020
"dependencies": {
2121
"chalk": "5",
22-
"commander": "12",
23-
"glob": "11",
24-
"minimatch": "10",
25-
"mkdirp": "3",
22+
"commander": "13",
2623
"underscore": "1",
2724
"watchy": "0.10"
2825
},

src/build-config.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import npath from 'path';
1+
import fs from 'node:fs/promises';
2+
import npath from 'node:path';
23

3-
import { glob } from 'glob';
44
import _ from 'underscore';
55

66
import getBuild from './get-build.js';
@@ -54,11 +54,20 @@ const saveBuild = async ({
5454
);
5555
};
5656

57-
const saveBuilds = ({ env, manifest, onError, onResult }) =>
58-
Promise.all(
57+
const saveBuilds = async ({ env, manifest, onError, onResult }) =>
58+
await Promise.all(
5959
_.map(env.builds, async (target, pattern) => {
60-
return Promise.all(
61-
_.map(await glob(pattern, { nodir: true }), async path => {
60+
const paths = (
61+
await Array.fromAsync(
62+
fs.glob(pattern, { exclude: () => true, withFileTypes: true })
63+
)
64+
).flatMap(dirent =>
65+
dirent.isDirectory()
66+
? []
67+
: npath.relative('.', npath.join(dirent.parentPath, dirent.name))
68+
);
69+
return await Promise.all(
70+
paths.map(async path => {
6271
try {
6372
const builds = flattenBuilds(
6473
await getBuild({

src/file-has-dependency.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import { minimatch } from 'minimatch';
1+
import npath from 'node:path';
2+
23
import _ from 'underscore';
34

45
export default ({ file: { builds, links }, path }) =>
5-
_.contains(builds, path) || _.any(links, link => minimatch(path, link));
6+
_.contains(builds, path) ||
7+
_.any(links, link => npath.matchesGlob(path, link));

src/filter-transformers.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
import { minimatch } from 'minimatch';
1+
import npath from 'node:path';
2+
23
import _ from 'underscore';
34

45
import toArray from './to-array.js';
56

67
const doesMatch = ({ transformer, path }) => {
78
const only = toArray(transformer.only);
89
const except = toArray(transformer.except);
9-
const match = _.partial(minimatch, path);
1010
return (
11-
(!only.length || _.any(only, match)) &&
12-
(!except.length || !_.any(except, match))
11+
(!only.length ||
12+
_.any(only, pattern => npath.matchesGlob(path, pattern))) &&
13+
(!except.length ||
14+
!_.any(except, pattern => npath.matchesGlob(path, pattern)))
1315
);
1416
};
1517

src/maybe-write.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import { promises as fs } from 'fs';
22
import npath from 'path';
33

4-
import { mkdirp } from 'mkdirp';
54
import _ from 'underscore';
65

76
export default async ({ buffer, targetPath }) => {
87
const targetBuffer = await fs.readFile(targetPath).catch(_.noop);
98
if (targetBuffer && buffer.compare(targetBuffer) === 0) return false;
109

11-
await mkdirp(npath.dirname(targetPath));
10+
await fs.mkdir(npath.dirname(targetPath), { recursive: true });
1211
await fs.writeFile(targetPath, buffer);
1312
return true;
1413
};

test-fixtures/transformer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ export default ({ file: { path } }) =>
2828
],
2929
builds: ['test-fixtures/a.txt']
3030
}
31-
}[path]);
31+
})[path];

0 commit comments

Comments
 (0)