@storm-stack/file-system
Advanced tools
Comparing version 1.2.1 to 1.3.0
@@ -145,2 +145,13 @@ /// <reference types="node" /> | ||
/** | ||
* Find the file extension from a file path. | ||
* | ||
* @param filePath - The file path to process | ||
* @returns The file extension | ||
*/ | ||
declare function findFileExtension(filePath: string): string; | ||
export { findFileExtension } | ||
export { findFileExtension as findFileExtension_alias_1 } | ||
export { findFileExtension as findFileExtension_alias_2 } | ||
/** | ||
* Find the file name from a file path. | ||
@@ -147,0 +158,0 @@ * |
@@ -145,2 +145,13 @@ /// <reference types="node" /> | ||
/** | ||
* Find the file extension from a file path. | ||
* | ||
* @param filePath - The file path to process | ||
* @returns The file extension | ||
*/ | ||
declare function findFileExtension(filePath: string): string; | ||
export { findFileExtension } | ||
export { findFileExtension as findFileExtension_alias_1 } | ||
export { findFileExtension as findFileExtension_alias_2 } | ||
/** | ||
* Find the file name from a file path. | ||
@@ -147,0 +158,0 @@ * |
@@ -145,2 +145,13 @@ /// <reference types="node" /> | ||
/** | ||
* Find the file extension from a file path. | ||
* | ||
* @param filePath - The file path to process | ||
* @returns The file extension | ||
*/ | ||
declare function findFileExtension(filePath: string): string; | ||
export { findFileExtension } | ||
export { findFileExtension as findFileExtension_alias_1 } | ||
export { findFileExtension as findFileExtension_alias_2 } | ||
/** | ||
* Find the file name from a file path. | ||
@@ -147,0 +158,0 @@ * |
@@ -145,2 +145,13 @@ /// <reference types="node" /> | ||
/** | ||
* Find the file extension from a file path. | ||
* | ||
* @param filePath - The file path to process | ||
* @returns The file extension | ||
*/ | ||
declare function findFileExtension(filePath: string): string; | ||
export { findFileExtension } | ||
export { findFileExtension as findFileExtension_alias_1 } | ||
export { findFileExtension as findFileExtension_alias_2 } | ||
/** | ||
* Find the file name from a file path. | ||
@@ -147,0 +158,0 @@ * |
@@ -145,2 +145,13 @@ /// <reference types="node" /> | ||
/** | ||
* Find the file extension from a file path. | ||
* | ||
* @param filePath - The file path to process | ||
* @returns The file extension | ||
*/ | ||
declare function findFileExtension(filePath: string): string; | ||
export { findFileExtension } | ||
export { findFileExtension as findFileExtension_alias_1 } | ||
export { findFileExtension as findFileExtension_alias_2 } | ||
/** | ||
* Find the file name from a file path. | ||
@@ -147,0 +158,0 @@ * |
@@ -145,2 +145,13 @@ /// <reference types="node" /> | ||
/** | ||
* Find the file extension from a file path. | ||
* | ||
* @param filePath - The file path to process | ||
* @returns The file extension | ||
*/ | ||
declare function findFileExtension(filePath: string): string; | ||
export { findFileExtension } | ||
export { findFileExtension as findFileExtension_alias_1 } | ||
export { findFileExtension as findFileExtension_alias_2 } | ||
/** | ||
* Find the file name from a file path. | ||
@@ -147,0 +158,0 @@ * |
{ | ||
"name": "@storm-stack/file-system", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "⚡ The storm-stack monorepo contains utility applications, tools, and various libraries to create modern and scalable web applications.", |
@@ -21,4 +21,6 @@ // | ||
import { dirname, isAbsolute, join, parse, relative, sep } from "node:path"; | ||
import { EMPTY_STRING } from "@storm-stack/utilities"; | ||
import { dirname, isAbsolute, parse, relative, sep } from "node:path"; | ||
import { getWorkspaceRoot } from "./get-workspace-root"; | ||
import { joinPaths } from "./join-paths"; | ||
@@ -51,2 +53,17 @@ /** | ||
/** | ||
* Find the file extension from a file path. | ||
* | ||
* @param filePath - The file path to process | ||
* @returns The file extension | ||
*/ | ||
export function findFileExtension(filePath: string): string { | ||
const splits = findFileName(filePath)?.split("."); | ||
if (splits && Array.isArray(splits) && splits.length > 0) { | ||
splits.pop(); | ||
} | ||
return splits.join(".") ?? EMPTY_STRING; | ||
} | ||
/** | ||
* Check if a file path has a file name. | ||
@@ -85,5 +102,5 @@ * | ||
} else if (basePath) { | ||
return join(dirname(basePath), filePath); | ||
return joinPaths(dirname(basePath), filePath); | ||
} else { | ||
return join(process.cwd(), filePath); | ||
return joinPaths(process.cwd(), filePath); | ||
} | ||
@@ -112,3 +129,3 @@ } | ||
const file = parse(filePath); | ||
return join( | ||
return joinPaths( | ||
file.dir, | ||
@@ -115,0 +132,0 @@ newFileName.includes(".") ? newFileName : newFileName + file.ext |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3332046
2786