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" * ``` *