smartfile/dist/smartfile.interpreter.js

23 lines
2.7 KiB
JavaScript
Raw Normal View History

"use strict";
require("typings-global");
var plugins = require("./smartfile.plugins");
2016-06-23 16:31:55 +00:00
exports.filetype = function (pathArg) {
var extName = plugins.path.extname(pathArg);
var fileType = extName.replace(/\.([a-z]*)/, "$1"); //remove . form fileType
return fileType;
};
exports.objectFile = function (fileStringArg, fileTypeArg) {
switch (fileTypeArg) {
case "yml":
case "yaml":
return plugins.yaml.safeLoad(fileStringArg);
case "json":
return JSON.parse(fileStringArg);
default:
plugins.beautylog.error("file type " + fileTypeArg.blue + " not supported");
break;
}
};
2016-06-23 16:31:55 +00:00
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0ZmlsZS5pbnRlcnByZXRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFBZ0IsQ0FBQyxDQUFBO0FBRXhCLElBQU8sT0FBTyxXQUFXLHFCQUFxQixDQUFDLENBQUM7QUFFckMsZ0JBQVEsR0FBRyxVQUFDLE9BQWM7SUFDakMsSUFBSSxPQUFPLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsT0FBTyxDQUFDLENBQUM7SUFDNUMsSUFBSSxRQUFRLEdBQUcsT0FBTyxDQUFDLE9BQU8sQ0FBQyxZQUFZLEVBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyx3QkFBd0I7SUFDM0UsTUFBTSxDQUFDLFFBQVEsQ0FBQztBQUNwQixDQUFDLENBQUM7QUFFUyxrQkFBVSxHQUFHLFVBQUMsYUFBb0IsRUFBRSxXQUFXO0lBQ3RELE1BQU0sQ0FBQyxDQUFDLFdBQVcsQ0FBQyxDQUFDLENBQUM7UUFDbEIsS0FBSyxLQUFLLENBQUU7UUFDWixLQUFLLE1BQU07WUFDUCxNQUFNLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxRQU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