checkPathWithMultipleExtensions

Type:Function
Status:stable
Since:1.0.0
Platform:node
@blackbyte.sugar.node.fs

This function take a path and some extensions to check if a file exists with one of these particular extensions. If a file exists, the function return the path with the first extensions that matches

Params

  1. path*-String

    The file path you want to check. With or without an extension

  2. extensions*-Array<String>

    The extensions (without the dot) you want to check

Return

  1. -String|undefined

    The first valid path founded, or undefined

Example

import { checkPathWithMultipleExtensions } from '@blackbyte/sugar/fs';
checkPathWithMultipleExtensions('/my/cool/file.txt', ['txt','js','css']);