now exposing home

This commit is contained in:
Philipp Kunz 2016-04-04 16:25:17 +02:00
parent fb62b0aac7
commit 209ff095a4
8 changed files with 51 additions and 8 deletions

15
dist/smartpath.get.js vendored
View File

@ -1,4 +1,9 @@
"use strict";
/// <reference path="typings/main.d.ts" />
var plugins = require("./smartpath.plugins");
/**
* returns the type of the given path. Can be "url" or "local"
*/
exports.type = function (pathStringArg) {
var urlRegex = /http[s|\s]:\/\/.*/i;
if (urlRegex.exec(pathStringArg)) {
@ -9,5 +14,13 @@ exports.type = function (pathStringArg) {
}
;
};
exports.home = function (pathArgument) {
if (pathArgument) {
return plugins.home.resolve(pathArgument);
}
else {
return plugins.home();
}
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0cGF0aC5nZXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUdXLFlBQUksR0FBRyxVQUFTLGFBQW9CO0lBQzNDLElBQUksUUFBUSxHQUFHLG9CQUFvQixDQUFBO0lBQ25DLEVBQUUsQ0FBQSxDQUFDLFFBQVEsQ0FBQyxJQUFJLENBQUMsYUFBYSxDQUFDLENBQUMsQ0FBQSxDQUFDO1FBQzdCLE1BQU0sQ0FBQyxLQUFLLENBQUM7SUFDakIsQ0FBQztJQUFDLElBQUksQ0FBQyxDQUFDO1FBQ0osTUFBTSxDQUFDLE9BQU8sQ0FBQztJQUNuQixDQUFDO0lBQUEsQ0FBQztBQUNOLENBQUMsQ0FBQyIsImZpbGUiOiJzbWFydHBhdGguZ2V0LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cInR5cGluZ3MvbWFpbi5kLnRzXCIgLz5cbmltcG9ydCBwbHVnaW5zID0gcmVxdWlyZShcIi4vc21hcnRwYXRoLnBsdWdpbnNcIik7XG5cbmV4cG9ydCBsZXQgdHlwZSA9IGZ1bmN0aW9uKHBhdGhTdHJpbmdBcmc6c3RyaW5nKTp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UFDLENBQUMiLCJmaWxlIjoic21hcnRwYXRoLmdldC5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8vLyA8cmVmZXJlbmNlIHBhdGg9XCJ0eXBpbmdzL21haW4uZC50c1wiIC8+XG5pbXBvcnQgcGx1Z2lucyA9IHJlcXVpcmUoXCIuL3NtYXJ0cGF0aC5wbHVnaW5zXCIpO1xuXG4vKipcbiAqIHJldHVybnMgdGhlIHR5cGUgb2YgdGhlIGdpdmVuIHBhdGguIENhbiBiZSBcInVybFwiIG9yIFwibG9jYWxcIlxuICovXG5leHBvcnQgbGV0IHR5cGUgPSBmdW5jdGlvbihwYXRoU3RyaW5nQXJnOnN0cmluZyk6c3RyaW5nIHtcbiAgICBsZXQgdXJsUmVnZXggPSAvaHR0cFtzfFxcc106XFwvXFwvLiovaVxuICAgIGlmKHVybFJlZ2V4LmV4ZWMocGF0aFN0cmluZ0FyZykpe1xuICAgICAgICByZXR1cm4gXCJ1cmxcIjtcbiAgICB9IGVsc2Uge1xuICAgICAgICByZXR1cm4gXCJsb2NhbFwiO1xuICAgIH07XG59O1xuXG5leHBvcnQgbGV0IGhvbWUgPSBmdW5jdGlvbihwYXRoQXJndW1lbnQ/OnN0cmluZyl7XG4gICAgaWYocGF0aEFyZ3VtZW50KXtcbiAgICAgICAgcmV0dXJuIHBsdWdpbnMuaG9tZS5yZXNvbHZlKHBhdGhBcmd1bWVudCk7XG4gICAgfSBlbHNlIHtcbiAgICAgICAgcmV0dXJuIHBsdWdpbnMuaG9tZSgpO1xuICAgIH1cbn07Il0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9

View File

@ -1,6 +1,7 @@
"use strict";
/// <reference path="./typings/main.d.ts" />
exports.beautylog = require("beautylog");
exports.home = require("home");
exports.path = require("path");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0cGF0aC5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOi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+22,11 @@
},
"homepage": "https://github.com/pushrocks/smartpath",
"dependencies": {
"beautylog": "^3.1.2"
"beautylog": "^3.1.2",
"home": "^1.0.1"
},
"devDependencies": {
"npmts": "^3.6.3",
"npmts": "^4.0.1",
"should": "^8.3.0"
}
}

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,IAAI,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC/B,IAAI,SAAS,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAE5C,QAAQ,CAAC,WAAW,EAAC;IACjB,QAAQ,CAAC,YAAY,EAAC;QAClB,QAAQ,CAAC,cAAc,EAAC;YACpB,IAAI,UAAU,GAAG,UAAU,CAAC;YAC5B,IAAI,cAAc,GAAG,sBAAsB,CAAC;YAC5C,IAAI,eAAe,GAAG,4BAA4B,CAAC;YACnD,IAAI,aAAa,GAAG,CAAC,cAAc,EAAC,cAAc,EAAC,eAAe,CAAC,CAAC;YACpE,EAAE,CAAC,+BAA+B,EAAC;gBAC/B,SAAS,CAAC,SAAS,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;gBACrE,SAAS,CAAC,SAAS,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;gBAC9E,SAAS,CAAC,SAAS,CAAC,UAAU,CAAC,cAAc,EAAC,UAAU,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;YAC5G,CAAC,CAAC,CAAC;YACH,EAAE,CAAC,uEAAuE,EAAC;gBACvE,IAAI,aAAa,GAAG,SAAS,CAAC,SAAS,CAAC,UAAU,CAAC,aAAa,EAAC,UAAU,CAAC,CAAC;gBAC7E,aAAa,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,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AgC,EAAC;gBAChC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBACtE,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAChF,CAAC,CAAC,CAAC;YACH,EAAE,CAAC,iCAAiC,EAAC;gBACjC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBACjE,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACxE,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;QACH,QAAQ,CAAC,QAAQ,EAAC;YACd,EAAE,CAAC,iDAAiD,EAAC;gBACjD,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC9C,CAAC,CAAC,CAAC;YACH,EAAE,CAAC,qEAAqE,EAAC;gBACrE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;YACtC,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}

View File

@ -36,5 +36,13 @@ describe("smartpath",function(){
smartpath.get.type("./some/relative/path/").should.not.equal("url");
});
});
describe(".get()",function(){
it("should a absolute path for an home relative URL",function(){
console.log(smartpath.get.home("~/test"));
});
it("should return the home directory path when no argument is specified",function(){
console.log(smartpath.get.home());
});
});
});
});

View File

@ -1,6 +1,9 @@
/// <reference path="typings/main.d.ts" />
import plugins = require("./smartpath.plugins");
/**
* returns the type of the given path. Can be "url" or "local"
*/
export let type = function(pathStringArg:string):string {
let urlRegex = /http[s|\s]:\/\/.*/i
if(urlRegex.exec(pathStringArg)){
@ -8,4 +11,12 @@ export let type = function(pathStringArg:string):string {
} else {
return "local";
};
};
export let home = function(pathArgument?:string){
if(pathArgument){
return plugins.home.resolve(pathArgument);
} else {
return plugins.home();
}
};

View File

@ -1,3 +1,5 @@
/// <reference path="./typings/main.d.ts" />
export var beautylog = require ("beautylog");
export var path = require("path");
export var home = require("home");
export var path = require("path");