smartfile/dist/smartfile.get.js

24 lines
3.4 KiB
JavaScript
Raw Normal View History

"use strict";
require("typings-global");
var plugins = require("./smartfile.plugins");
exports.filetype = function (pathArg) {
var extName = plugins.path.extname(pathArg);
var fileType = extName.replace(/\.([a-z]*)/, "$1"); //remove . form fileType
return fileType;
};
exports.foldersSync = function (pathArg) {
return plugins.fs.readdirSync(pathArg).filter(function (file) {
return plugins.fs.statSync(plugins.path.join(pathArg, file)).isDirectory();
});
};
exports.folders = function (pathArg) {
var done = plugins.q.defer();
var folderArray = plugins.fs.readdirSync(pathArg).filter(function (file) {
return plugins.fs.statSync(plugins.path.join(pathArg, file)).isDirectory();
});
done.resolve(folderArray);
return done.promise;
};
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0ZmlsZS5nZXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUN4QixJQUFPLE9BQU8sV0FBVyxxQkFBcUIsQ0FBQyxDQUFDO0FBRXJDLGdCQUFRLEdBQUcsVUFBUyxPQUFjO0lBQ3pDLElBQUksT0FBTyxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLE9BQU8sQ0FBQyxDQUFDO0lBQzVDLElBQUksUUFBUSxHQUFHLE9BQU8sQ0FBQyxPQUFPLENBQUMsWUFBWSxFQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsd0JBQXdCO0lBQzNFLE1BQU0sQ0FBQyxRQUFRLENBQUM7QUFDcEIsQ0FBQyxDQUFDO0FBRVMsbUJBQVcsR0FBRyxVQUFTLE9BQU87SUFDckMsTUFBTSxDQUFDLE9BQU8sQ0FBQyxFQUFFLENBQUMsV0FBVyxDQUFDLE9BQU8sQ0FBQyxDQUFDLE1BQU0sQ0FBQyxVQUFTLElBQUk7UUFDdkQsTUFBTSxDQUFDLE9BQU8sQ0FBQyx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