Skip to content

Commit d82eacb

Browse files
committed
Release 4.9.9
1 parent 5fb07a3 commit d82eacb

5 files changed

Lines changed: 11 additions & 15 deletions

File tree

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.9.8",
3+
"version": "4.9.9",
44
"type": "module",
55
"author": "Casey Foster <c@sey.me>",
66
"description": "The fast file transform pipeline.",

src/build-config.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import fs from 'node:fs/promises';
2-
import { join, relative } from 'node:path';
2+
import { extname, join, relative } from 'node:path';
33

44
import getBuilds from '#src/get-builds.js';
5-
import { getExt } from '#src/get-ext.js';
65
import maybeWrite from '#src/maybe-write.js';
76
import setExt from '#src/set-ext.js';
87
import sortObj from '#src/sort-obj.js';
@@ -37,7 +36,7 @@ const saveBuild = async ({
3736
buffers.map(async (buffer, i) => {
3837
const size = buffer.length;
3938
const sourcePath =
40-
i === 0 ? path : setExt(path, `~${i + 1}${getExt(path)}`);
39+
i === 0 ? path : setExt(path, `~${i + 1}${extname(path)}`);
4140
try {
4241
const { didChange, targetPath } = await writeBuffer({
4342
buffer,

src/get-ext.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/get-target-path.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import crypto from 'crypto';
2-
import { join, relative } from 'path';
2+
import { extname, join, relative } from 'path';
33

4-
import { getExt } from '#src/get-ext.js';
54
import setExt from '#src/set-ext.js';
65

76
const getHash = buffer => {
@@ -15,9 +14,9 @@ export default ({
1514
path,
1615
target: { base = '.', dir = '.', ext = {}, fingerprint = false } = {}
1716
}) => {
18-
const oldExt = getExt(path);
19-
return setExt(
20-
join(dir, relative(base, path).replace(/\.\./g, '__')),
21-
(fingerprint ? `~${getHash(buffer)}` : '') + (ext[oldExt] ?? oldExt)
22-
);
17+
path = join(dir, relative(base, path).replace(/\.\./g, '__'));
18+
const newExt = ext[extname(path)];
19+
if (newExt != null) path = setExt(path, newExt);
20+
if (fingerprint) path = setExt(path, `~${getHash(buffer)}${extname(path)}`);
21+
return path;
2322
};

src/set-ext.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getExt } from '#src/get-ext.js';
1+
import { extname } from 'node:path';
22

33
export default (path, newExt) =>
4-
`${path.slice(0, path.length - getExt(path).length)}${newExt}`;
4+
`${path.slice(0, path.length - extname(path).length)}${newExt}`;

0 commit comments

Comments
 (0)