2016-03-20 16:36:38 +00:00
|
|
|
"use strict";
|
2017-03-04 20:10:46 +00:00
|
|
|
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) => {
|
2016-03-20 16:36:38 +00:00
|
|
|
switch (fileTypeArg) {
|
2016-09-20 15:56:49 +00:00
|
|
|
case 'yml':
|
|
|
|
case 'yaml':
|
2016-03-20 16:36:38 +00:00
|
|
|
return plugins.yaml.safeLoad(fileStringArg);
|
2016-09-20 15:56:49 +00:00
|
|
|
case 'json':
|
2016-03-20 16:36:38 +00:00
|
|
|
return JSON.parse(fileStringArg);
|
|
|
|
default:
|
2017-01-21 11:11:22 +00:00
|
|
|
console.error('file type ' + fileTypeArg.blue + ' not supported');
|
2016-03-20 16:36:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
};
|
2018-07-03 22:59:39 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRmaWxlLmludGVycHJldGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRmaWxlLmludGVycHJldGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsK0NBQWdEO0FBRXJDLFFBQUEsUUFBUSxHQUFHLENBQUMsT0FBZSxFQUFVLEVBQUU7SUFDaEQsSUFBSSxPQUFPLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsT0FBTyxDQUFDLENBQUM7SUFD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