2024-04-02 18:53:02 +00:00
|
|
|
import * as plugins from './plugins.js';
|
2016-03-20 16:36:38 +00:00
|
|
|
|
2016-09-20 15:56:49 +00:00
|
|
|
export let filetype = (pathArg: string): string => {
|
2019-09-27 09:00:17 +00:00
|
|
|
const extName = plugins.path.extname(pathArg);
|
|
|
|
const fileType = extName.replace(/\.([a-z]*)/, '$1'); // remove . form fileType
|
2018-07-03 06:55:09 +00:00
|
|
|
return fileType;
|
|
|
|
};
|
2016-06-23 16:31:55 +00:00
|
|
|
|
2016-09-20 15:56:49 +00:00
|
|
|
export let objectFile = (fileStringArg: string, fileTypeArg) => {
|
2018-07-03 06:55:09 +00:00
|
|
|
switch (fileTypeArg) {
|
|
|
|
case 'yml':
|
|
|
|
case 'yaml':
|
2021-04-07 09:48:54 +00:00
|
|
|
return plugins.yaml.load(fileStringArg);
|
2018-07-03 06:55:09 +00:00
|
|
|
case 'json':
|
|
|
|
return JSON.parse(fileStringArg);
|
|
|
|
default:
|
|
|
|
console.error('file type ' + fileTypeArg.blue + ' not supported');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
};
|