This commit is contained in:
2023-11-04 20:07:43 +01:00
parent 8b07197224
commit ca592afec9
12 changed files with 281 additions and 147 deletions

20
ts/interpreter.ts Normal file
View File

@@ -0,0 +1,20 @@
import * as plugins from './smartfile.plugins.js';
export let filetype = (pathArg: string): string => {
const extName = plugins.path.extname(pathArg);
const fileType = extName.replace(/\.([a-z]*)/, '$1'); // remove . form fileType
return fileType;
};
export let objectFile = (fileStringArg: string, fileTypeArg) => {
switch (fileTypeArg) {
case 'yml':
case 'yaml':
return plugins.yaml.load(fileStringArg);
case 'json':
return JSON.parse(fileStringArg);
default:
console.error('file type ' + fileTypeArg.blue + ' not supported');
break;
}
};