2022-07-20 23:47:41 +02:00
|
|
|
/**
|
2022-07-22 11:46:47 +02:00
|
|
|
* Log module status.
|
2022-07-20 23:47:41 +02:00
|
|
|
* @param {string} name Module name
|
|
|
|
* @param {boolean} status Module status
|
|
|
|
* @returns String
|
|
|
|
*/
|
|
|
|
export const logStart = (name: string, status: boolean) => {
|
|
|
|
return `> ${name} ${status === true ? '✅' : '❌'}`;
|
|
|
|
};
|
2022-07-22 11:46:47 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Filename without path and extension.
|
|
|
|
* @param path __filename
|
|
|
|
* @returns string
|
|
|
|
*/
|
|
|
|
export const getFilename = (path: string) => {
|
|
|
|
const path_list = path.split('/');
|
|
|
|
|
|
|
|
// Check if filename exist
|
|
|
|
const filename_with_ext = path_list.pop();
|
|
|
|
if (filename_with_ext === undefined) {
|
|
|
|
throw new Error(`Filename error: don't exist in ${path}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
return removeExtension(filename_with_ext);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove extension from a filename.
|
|
|
|
* @param filename string of the filename with an extension
|
|
|
|
* @returns string of the filename without an extension
|
|
|
|
*/
|
|
|
|
export const removeExtension = (filename: string) => {
|
|
|
|
const array = filename.split('.');
|
|
|
|
array.pop();
|
|
|
|
|
|
|
|
return array.join('.');
|
|
|
|
};
|