From 4127cd1bfdd10f46c4f8954cb9dbf810f4bf7a98 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 19 Aug 2022 02:12:43 -0700 Subject: [PATCH] chore: add an example for addShRelativePrefix [skip ci] --- README.md | 7 +++++++ src/add-sh-relative-prefix.ts | 8 ++++++++ src/remove-ext.ts | 1 + 3 files changed, 16 insertions(+) diff --git a/README.md b/README.md index bf3d365..a563c58 100644 --- a/README.md +++ b/README.md @@ -155,6 +155,12 @@ Prefix a `./` for unix shell and nothing for `cmd`. **returns:** string +```js +import { addShRelativePrefix } from "patha" + +addShRelativePrefix("some/file-name") // gives "some/file-name" on Windows and "./some/file-name" on others. +``` + ### `name` (function) Get the name of the given file path. @@ -206,6 +212,7 @@ Remove a path's extension. ```js import { removeExt } from "patha" + removeExt("some/dir/file.ext") // gives "some/dir/file" ``` diff --git a/src/add-sh-relative-prefix.ts b/src/add-sh-relative-prefix.ts index f4a33d5..1f2d7b3 100644 --- a/src/add-sh-relative-prefix.ts +++ b/src/add-sh-relative-prefix.ts @@ -1,6 +1,14 @@ /** * Prefix a `./` for unix shell and nothing for `cmd`. * + * @example + * + * ```js + * import { addShRelativePrefix } from "patha" + * + * addShRelativePrefix("some/file-name") // gives "some/file-name" on Windows and "./some/file-name" on others. + * ``` + * * @param path The given path * @returns The path with `./` added on Unix */ diff --git a/src/remove-ext.ts b/src/remove-ext.ts index fedaafc..8c6ce1c 100644 --- a/src/remove-ext.ts +++ b/src/remove-ext.ts @@ -7,6 +7,7 @@ import { extname } from "path" * * ```js * import { removeExt } from "patha" + * * removeExt("some/dir/file.ext") // gives "some/dir/file" * ``` *