smartfile/dist/smartfile.interpreter.js

21 lines
1.7 KiB
JavaScript
Raw Normal View History

"use strict";
require("typings-global");
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:
2016-09-20 15:56:49 +00:00
plugins.beautylog.error('file type ' + fileTypeArg.blue + ' not supported');
break;
}
};
2016-09-20 15:56:49 +00:00
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRmaWxlLmludGVycHJldGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRmaWxlLmludGVycHJldGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSwwQkFBdUI7QUFFdkIsK0NBQStDO0FBRXBDLFFBQUEsUUFBUSxHQUFHLENBQUMsT0FBZTtJQUNsQyxJQUFJLE9BQU8sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FBQTtJQUMzQyxJQUFJLFFBQVEsR0FBRyxPQUFPLENBQUMsT0FBTyxDQUFDLFlBQVksRUFBQyxJQUFJLENBQUMsQ0FBQSxDQUFDLHlCQUF5QjtJQUMzRSxNQUFNLENBQUMsUUFBUSxDQUFBO0FBQ25CLENBQUMsQ0FBQTtBQUVVLFFBQUEsVUFBVSxHQUFHLENBQUMsYUFBcUIsRUFBRSxXQUFXO0lBQ3ZELE1BQU0sQ0FBQyx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