added check module
This commit is contained in:
		
							
								
								
									
										10
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										10
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							@@ -1,14 +1,16 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
var SmartpathTransform = require("./smartpath.transform");
 | 
			
		||||
var SmartpathCheck = require("./smartpath.check");
 | 
			
		||||
var SmartpathGet = require("./smartpath.get");
 | 
			
		||||
var SmartpathTransform = require("./smartpath.transform");
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @type {{getPath: (function(any): undefined)}}
 | 
			
		||||
 */
 | 
			
		||||
var smartpath = {
 | 
			
		||||
    transform: SmartpathTransform,
 | 
			
		||||
    get: SmartpathGet
 | 
			
		||||
    check: SmartpathCheck,
 | 
			
		||||
    get: SmartpathGet,
 | 
			
		||||
    transform: SmartpathTransform
 | 
			
		||||
};
 | 
			
		||||
module.exports = smartpath;
 | 
			
		||||
 | 
			
		||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFFQSxJQUFPLGtCQUFrQixXQUFXLHVCQUF1QixDQUFDLENBQUM7QUFDN0QsSUFBTyxZQUFZLFdBQVcsaUJBQWlCLENBQUMsQ0FBQztBQUVqRDs7O0dBR0c7QUFDSCxJQUFJLFNBQVMsR0FBRztJQUNaLFNBQVMsRUFBRSxrQkFBa0I7SUFDN0IsR0FBRyxFQUFFLFlBQVk7Q0FFcEIsQ0FBQztBQUdGLGlCQUFTLFNBQVMsQ0FBQyIsImZpbGUiOiJpbmRleC5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8vLyA8cmVmZXJlbmNlIHBhdGg9XCJ0eXBpbmdzL21haW4uZC50c1wiIC8+XG5pbXBvcnQgcGx1Z2lucyA9IHJlcXVpcmUoXCIuL3NtYXJ0cGF0aC5wbHVnaW5zX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nRwYXRoQ2hlY2sgPSByZXF1aXJlKFwiLi9zbWFydHBhdGguY2hlY2tcIik7XG5pbXBvcnQgU21hcnRwYXRoR2V0ID0gcmVxdWlyZShcIi4vc21hcnRwYXRoLmdldFwiKTtcbmltcG9ydCBTbWFydHBhdGhUcmFuc2Zvcm0gPSByZXF1aXJlKFwiLi9zbWFydHBhdGgudHJhbnNmb3JtXCIpO1xuXG4vKipcbiAqXG4gKiBAdHlwZSB7e2dldFBhdGg6IChmdW5jdGlvbihhbnkpOiB1bmRlZmluZWQpfX1cbiAqL1xubGV0IHNtYXJ0cGF0aCA9IHtcbiAgICBjaGVjazogU21hcnRwYXRoQ2hlY2ssXG4gICAgZ2V0OiBTbWFydHBhdGhHZXQsXG4gICAgdHJhbnNmb3JtOiBTbWFydHBhdGhUcmFuc2Zvcm1cbn07XG5cblxuZXhwb3J0ID0gc21hcnRwYXRoO1xuIl0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										9
									
								
								dist/smartpath.check.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								dist/smartpath.check.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,9 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
exports.isDir = function (pathArg) {
 | 
			
		||||
    return !exports.isFile(pathArg);
 | 
			
		||||
};
 | 
			
		||||
exports.isFile = function (pathArg) {
 | 
			
		||||
    return /\.[a-zA-Z]*$/.test(pathArg); // checks if there is a .anything at the end
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0cGF0aC5jaGVjay50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBRVcsYUFBSyxHQUFHLFVBQVMsT0FBYztJQUN0QyxNQUFNLENBQUMsQ0FBQyxjQUFNLENBQUMsT0FBTyxDQUFDLENBQUM7QUFDNUIsQ0FBQyxDQUFBO0FBRVUsY0FBTSxHQUFHLFVBQVMsT0FBTztJQUNoQyxNQUFNLENBQUMsY0FBYyxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsQ0FBQyxDQUFDLDRDQUE0QztBQUNyRixDQUFDLENBQUEiLCJmaWxlIjoic21hcnRwYXRoLmNoZWNrLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHBsdWdpbnMgPSByZXF1aXJlKFwiLi9zbWFydHBhdGgucGx1Z2luc1wiKTtcblxuZXhwb3J0IGxldCBpc0RpciA9IGZ1bmN0aW9uKHBhdGhBcmc6c3RyaW5nKXtcbiAgICByZXR1cm4gIWlzRmlsZShwYXRoQXJnKTtcbn1cblxuZXhwb3J0IGxldCBpc0ZpbGUgPSBmdW5jdGlvbihwYXRoQXJnKXtcbiAgICByZXR1cm4gL1xcLlthLXpBLVpdKiQvLnRlc3QocGF0aEFyZyk7IC8vIGNoZWNrcyBpZiB0aGVyZSBpcyBhIC5hbnl0aGluZyBhdCB0aGUgZW5kXG59Il0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9
 | 
			
		||||
@@ -22,11 +22,11 @@
 | 
			
		||||
  },
 | 
			
		||||
  "homepage": "https://github.com/pushrocks/smartpath",
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "beautylog": "^4.1.1",
 | 
			
		||||
    "beautylog": "^4.1.2",
 | 
			
		||||
    "home": "^1.0.1"
 | 
			
		||||
  },
 | 
			
		||||
  "devDependencies": {
 | 
			
		||||
    "npmts": "^5.0.3",
 | 
			
		||||
    "should": "^8.3.0"
 | 
			
		||||
    "npmts": "^5.0.4",
 | 
			
		||||
    "should": "^8.3.1"
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										32
									
								
								test/test.js
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								test/test.js
									
									
									
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										29
									
								
								test/test.ts
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								test/test.ts
									
									
									
									
									
								
							@@ -3,6 +3,35 @@ let should = require("should");
 | 
			
		||||
let smartpath = require("../dist/index.js");
 | 
			
		||||
 | 
			
		||||
describe("smartpath",function(){
 | 
			
		||||
    describe(".check",function(){
 | 
			
		||||
        let filePathString = "./somedir/somefile.json"
 | 
			
		||||
        let dirPathString = "./somedir/anotherdir"
 | 
			
		||||
        let dirPathString2 = "./somedir/another.dir/"
 | 
			
		||||
        describe(".isFile",function(){
 | 
			
		||||
            it("should be true for a file path",function(){
 | 
			
		||||
                smartpath.check.isFile(filePathString)
 | 
			
		||||
                    .should.be.true();
 | 
			
		||||
            });
 | 
			
		||||
            it("should be false for a directory path",function(){
 | 
			
		||||
                smartpath.check.isFile(dirPathString)
 | 
			
		||||
                    .should.be.false();
 | 
			
		||||
                smartpath.check.isFile(dirPathString2)
 | 
			
		||||
                    .should.be.false();
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
        describe(".isDir",function(){
 | 
			
		||||
            it("should be true for a directory path",function(){
 | 
			
		||||
                smartpath.check.isDir(dirPathString)
 | 
			
		||||
                    .should.be.true();
 | 
			
		||||
                smartpath.check.isDir(dirPathString2)
 | 
			
		||||
                    .should.be.true();
 | 
			
		||||
            });
 | 
			
		||||
            it("should be false for a file path",function(){
 | 
			
		||||
                smartpath.check.isDir(filePathString)
 | 
			
		||||
                    .should.be.false();
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
    describe(".transform",function(){
 | 
			
		||||
        describe("toAbsolute()",function(){
 | 
			
		||||
            let baseString = "/basedir";
 | 
			
		||||
 
 | 
			
		||||
@@ -1,16 +1,17 @@
 | 
			
		||||
/// <reference path="typings/main.d.ts" />
 | 
			
		||||
import plugins = require("./smartpath.plugins");
 | 
			
		||||
import SmartpathTransform = require("./smartpath.transform");
 | 
			
		||||
import SmartpathCheck = require("./smartpath.check");
 | 
			
		||||
import SmartpathGet = require("./smartpath.get");
 | 
			
		||||
import SmartpathTransform = require("./smartpath.transform");
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @type {{getPath: (function(any): undefined)}}
 | 
			
		||||
 */
 | 
			
		||||
let smartpath = {
 | 
			
		||||
    transform: SmartpathTransform,
 | 
			
		||||
    get: SmartpathGet
 | 
			
		||||
 | 
			
		||||
    check: SmartpathCheck,
 | 
			
		||||
    get: SmartpathGet,
 | 
			
		||||
    transform: SmartpathTransform
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										9
									
								
								ts/smartpath.check.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								ts/smartpath.check.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,9 @@
 | 
			
		||||
import plugins = require("./smartpath.plugins");
 | 
			
		||||
 | 
			
		||||
export let isDir = function(pathArg:string){
 | 
			
		||||
    return !isFile(pathArg);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export let isFile = function(pathArg){
 | 
			
		||||
    return /\.[a-zA-Z]*$/.test(pathArg); // checks if there is a .anything at the end
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user