Skip to content

Commit 27701bb

Browse files
committed
feat: add join method that deprecates joinPaths
This adds some naming compatibility compared with `node:path` module. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent cf362e8 commit 27701bb

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

lib/index.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,21 @@ export function dirname(path: string): string {
3838
}
3939

4040
/**
41-
* Join path sections
41+
* Joins multiple path segments into a single path.
42+
*
43+
* @param args - The path segments to join
44+
* @deprecated use `join()` instead
4245
*/
43-
export function joinPaths(...args: string[]) {
46+
export function joinPaths(...args: string[]): string {
47+
return join(...args)
48+
}
49+
50+
/**
51+
* Joins multiple path segments into a single path.
52+
*
53+
* @param args - The path segments to join
54+
*/
55+
export function join(...args: string[]): string {
4456
if (arguments.length < 1) {
4557
return ''
4658
}

test/joinPaths.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
* SPDX-License-Identifier: GPL-3.0-or-later
44
*/
55
import { describe, expect, it } from 'vitest';
6-
import { joinPaths } from "../lib/index";
6+
import { joinPaths, join } from "../lib/index";
77

8-
describe("joinPaths", function () {
8+
describe.for([join, joinPaths])("joinPaths", (joinPaths) => {
99
it("returns empty string with no or empty arguments", function () {
1010
expect(joinPaths()).toEqual("");
1111
expect(joinPaths("")).toEqual("");

0 commit comments

Comments
 (0)