smartfile/dist/smartfile.interpreter.js

21 lines
1.6 KiB
JavaScript
Raw Normal View History

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
2016-07-17 15:34:15 +00:00
const plugins = require("./smartfile.plugins");
exports.filetype = (pathArg) => {
let extName = plugins.path.extname(pathArg);
2016-09-20 15:56:49 +00:00
let fileType = extName.replace(/\.([a-z]*)/, '$1'); // remove . form fileType
2016-06-23 16:31:55 +00:00
return fileType;
};
2016-07-17 15:34:15 +00:00
exports.objectFile = (fileStringArg, fileTypeArg) => {
switch (fileTypeArg) {
2016-09-20 15:56:49 +00:00
case 'yml':
case 'yaml':
return plugins.yaml.safeLoad(fileStringArg);
2016-09-20 15:56:49 +00:00
case 'json':
return JSON.parse(fileStringArg);
default:
2017-01-21 11:11:22 +00:00
console.error('file type ' + fileTypeArg.blue + ' not supported');
break;
}
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRmaWxlLmludGVycHJldGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRmaWxlLmludGVycHJldGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsK0NBQStDO0FBRXBDLFFBQUEsUUFBUSxHQUFHLENBQUMsT0FBZSxFQUFVLEVBQUU7SUFDOUMsSUFBSSxPQUFPLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsT0FBTyxDQUFDLENBQUE7SUFDM0MsSUFBSSxRQUFRLEdBQUcsT0FBTyxDQUFDLE9BQU8sQ0FBQyxZQUFZLEVBQUMsSUFBSSxDQUFDLENBQUEsQ0FBQyx5QkFBeUI7SUFDM0UsT0FBTyxRQUFRLENBQUE7QUFDbkIsQ0FBQyxDQUFBO0FBRVUsUUFBQSxVQUFVLEdBQUcsQ0FBQyxhQUFxQixFQUFFLFdBQVcsRUFBRSxFQUFFO0lBQzNELFFBQVEsV0FBVyxFQUFFO1FBQ2pCLEtBQUssS0FBSyxDQUFFO1FBQ1osS0FBSyxNQUFNO1lBQ1AsT0FBTyxPQUFPLENBQUMsSUFBSSxDQUFDLFFBQVEsQ0FBQyxhQUFhLENBQUMsQ0FBQTtRQUMvQyxLQUFLLE1BQU07WUFDUCxPQUFPLElBQUksQ0FBQyxLQUFLLENBQUMsYUFBYSxDQUFDLENBQUE7UUFDcEM7WUFDSSxPQUFPLENBQUMsS0FBSyxDQUFDLFlBQVksR0FBRyxXQUFXLENBQUMsSUFBSSxHQUFHLGdCQUFnQixDQUFDLENBQUE7WUFDakUsTUFBSztLQUNaO0FBQ0wsQ0FBQyxDQUFBIn0=