add travis

This commit is contained in:
Philipp Kunz 2016-03-12 09:36:30 +01:00
parent 48f44ee937
commit 8a2afe1a81
11 changed files with 82 additions and 20 deletions

View File

@ -1,16 +1,16 @@
language: node_js
before_install:
- nvm install stable
- node -v
- npm -v
- npm install -g gulp
- npm install gulp
- npm install gulp-typescript
- nvm install stable
- node -v
- npm -v
- npm install -g gulp
- npm install gulp
- npm install gulp-typescript
deploy:
provider: npm
email: npm@smart-coordination.com
email: npm@lossless.digital
api_key:
secure: hfuRCg2RSNTvSe49w+rqx/fPt2OILDTjdYkga5BnGr0Rja5yL/2SpVNOP62lYNQBB61TfqfT8F4gQsQyAuygzhNT1ijZ4qCvSdqHqXki/0hzTVZAvfF2aoLxUnuCMAYawUyx5nibJKCmGXvH9MbMrEwV5Gh0uSf0HRmskp/GKuXw5epnMkOT2SEr9Mw7Hpu3VKLEALoKOI2hYBRv555sRFkI3Cd9v1n0384HEjCbQEwXhPwwki2XL2SXzGP8IOccE3xLK9zsQO2RDCqaKpIsK682ZtrvyqxmAJaivtO6VImkpBXcKniYOqJR6sWrsw5345er/iSSr30fgjw4I6LNyUcmF59Uw/dPAElvLN6jU6zxg/+GHM7xqz/J/HV3rlE4d20/9ZJB9IIm2761c3T7DraBMbA7ehj1lolTvCq1vx8oGbNEhkTVBj06V3ltdMPHMiNbeG2Tqs50h/lOgRy5+oqZ8ULWayWX1KXloM3LlddXJnnB31LzHbZUZw7m+q8QnfBlPCWuLd1JfluFrszr1YAR6YPciL9grBNV7beG+8wbh2G0gfMdCHZOzhDmoEHgt/y8liV0QdsFH6QLlEwt8UMPeZ8IO0sNYx5A2ffznZIzy9xEDmMySwl8J3/EdQxhS6FGrm000lu4BH+c2dVlCn/5va9fJLD+m6seSN8Yy40=
secure: C21gKjjg4W61RQlDo9vCjXjJ5NRvEoLuKe8IcKrTXEnn5R3ewnHfpgAQtXuBLvYuP6mIS6N2UxhcIo3BpsII1oOC4iJ4i3wqf6CH9hkmD1ejJe7qRiMKxltN0/4DHioySuolfcimKnOKSMGNQpOnze9lxqNi/qjUIgdsEY7soJRLIR9JQmhBBcRHoSzhxm6AnDmgEO75QsDIyhDH4wkWkOCOhRhjSfFNI6rm/om0XBRYkCKeNfz+Oqosnr8EkMVzsiRebLLXwZxzyCGSVFYQobtLxVqZDK5fvcz/GPyCbpDG/pZq5lxEkFYRiq+OmlIQn9Hz4C0i8VlXevS0ZatwS9iCGmG0/4ayUc2ksasY8o+bUfPJju0vKsCJJhtIj1e4GEj0ubisKirBOb5Oj8tMdf9RGLeNztFKRZEaM/ZoJ0gN//R9p4vWUZGMqJeIWh4I0hXA5Lv2OTUSl2h9bJ+Z678cb1k40w8bEVOij9GnUGQHybNwXV+8LZckap29/XDxguxtnYnuoX7L/dUfjkhK6JQRS9c7NDWOSzsnsy5kx0jHNaHac7vxMzmbdSRK71rNkzudtu2ECxONDc8aUNJLmUfL1tgYWt9/t9ramBqtmpp3w0S+s82PDHtoxAn02lWi2pz8pSp9ACP105qtUD9/1TCWtQUbYoL00QhFmlKzWwg=
on:
tags: true
repo: pushrocks/smartpath

View File

@ -1,2 +1,6 @@
# smartpath
offers smart ways to handle paths
## Status
## Documentation

7
dist/index.js vendored
View File

@ -1,8 +1,11 @@
var SmartpathAbsolute = require("./smartpath.absolute");
/**
*
* @type {{getPath: (function(any): undefined)}}
*/
var smartpath = {};
var smartpath = {
absolute: SmartpathAbsolute
};
module.exports = smartpath;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUtBOzs7R0FHRztBQUNILElBQUksU0FBUyxHQUFHLEVBRWYsQ0FBQztBQUdGLE1BQU0sQ0FBQyxPQUFPLEdBQUcsU0FBUyxDQUFDIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cInR5cGluZ3MvbWFpbi5kLnRzXCI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PSBzbWFydHBhdGg7XG4iXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=

View File

@ -12,13 +12,13 @@ var makeAbsolute = function (localPathArg, baseArg) {
};
var absolute = function (relativeArg, baseArg) {
if (typeof relativeArg === "string") {
return makeAbsolute(relativeArg);
return makeAbsolute(relativeArg, baseArg);
}
else if (Array.isArray(relativeArg)) {
var relativeArray = relativeArg;
var absoluteArray;
var absoluteArray = [];
for (var key in relativeArray) {
absoluteArray.push(makeAbsolute(relativeArray[key]));
absoluteArray.push(makeAbsolute(relativeArray[key], baseArg));
}
;
return absoluteArray;
@ -31,4 +31,4 @@ var absolute = function (relativeArg, baseArg) {
};
module.exports = absolute;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0cGF0aC5hYnNvbHV0ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSwwQ0FBMEM7QUFDMUMsSUFBTyxPQUFPLFdBQVcscUJBQXFCLENBQUMsQ0FBQztBQUVoRCxJQUFJLFlBQVksR0FBRyxVQUFTLFlBQW1CLEVBQUUsT0FBZTtJQUM1RCxJQUFJLFlBQW1CLENBQUM7SUFDeEIsRUFBRSxDQUFBLENBQUMsT0FBTyxDQUFDLENBQUEsQ0FBQztRQUNSLFlBQVksR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxPQUFPLEVBQUMsWUFBWSxDQUFDLENBQUM7SUFDM0QsQ0FBQztJQUFDLElBQUksQ0FBQyxDQUFDO1FBQ0gsWUFBWSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLFlBQVksQ0FBQyxDQUFDO0lBQ3ZELENBQUM7SUFDRCxNQUFNLENBQUMsWUFBWSxDQUFDO0FBQ3hCLENBQUMsQ0FBQztBQUVGLElBQUksUUFBUSxHQUFHLFVBQVMsV0FBZSxFQUFFLE9BQWU7SUFDcEQsRUFBRSxDQUF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jYWxQYXRoQXJnKTtcbiAgICB9XG4gICAgcmV0dXJuIGFic29sdXRlUGF0aDtcbn07XG5cbnZhciBhYnNvbHV0ZSA9IGZ1bmN0aW9uKHJlbGF0aXZlQXJnOmFueSwgYmFzZUFyZz86c3RyaW5nKTphbnkge1xuICAgIGlmKHR5cGVvZiByZWxhdGl2ZUFyZyA9PT0gXCJzdHJpbmdcIil7XG4gICAgICAgIHJldHVybiBtYWtlQWJzb2x1dGUocmVsYXRpdmVBcmcsYmFzZUFyZyk7XG4gICAgfSBlbHNlIGlmKEFycmF5LmlzQXJyYXkocmVsYXRpdmVBcmcpKXtcbiAgICAgICAgbGV0IHJlbGF0aXZlQXJyYXkgPSByZWxhdGl2ZUFyZ1xuICAgICAgICBsZXQgYWJzb2x1dGVBcnJheTpzdHJpbmdbXSA9IFtdO1xuICAgICAgICBmb3IgKGxldCBrZXkgaW4gcmVsYXRpdmVBcnJheSl7XG4gICAgICAgICAgICBhYnNvbHV0ZUFycmF5LnB1c2gobWFrZUFic29sdXRlKHJlbGF0aXZlQXJyYXlba2V5XSxiYXNlQXJnKSk7XG4gICAgICAgIH07XG4gICAgICAgIHJldHVybiBhYnNvbHV0ZUFycmF5O1xuICAgIH0gZWxzZSB7XG4gICAgICAgIHBsdWdpbnMuYmVhdXR5bG9nLmVycm9yKFwic21hcnRwYXRoLmFic29sdXRlKCkgY291bGQgbm90IG1ha2Ugc2Vuc2Ugb2YgdGhlIGlucHV0LiBcIiArXG4gICAgICAgICAgICBcIklucHV0IGlzIG5laXRoZXIgU3RyaW5nIG5vciBBcnJheVwiKTtcbiAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH1cbn07XG5cbmV4cG9ydCA9IGFic29sdXRlOyJdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==

View File

@ -25,6 +25,7 @@
"beautylog": "^3.1.2"
},
"devDependencies": {
"npmts": "^3.3.2"
"npmts": "^3.3.2",
"should": "^8.2.2"
}
}

26
test/test.js Normal file
View File

@ -0,0 +1,26 @@
/// <reference path="../ts/typings/main.d.ts" />
var should = require("should");
var smartpath = require("../dist/index.js");
describe("smartpath", function () {
describe("absolute()", function () {
var baseString = "/basedir";
var relativeString = "somedir/somefile.txt";
var relativeString2 = "anotherdir/anotherfile.txt";
var relativeArray = [relativeString, relativeString, relativeString2];
it("should make a string absolute", function () {
smartpath.absolute(relativeString).should.startWith("/");
smartpath.absolute(relativeString).should.endWith(relativeString);
smartpath.absolute(relativeString, baseString).should.equal("/basedir/somedir/somefile.txt");
});
it("should make an array of relative Strings an Array of absolute Strings", function () {
var absoluteArray = smartpath.absolute(relativeArray);
absoluteArray[2].should.startWith("/");
absoluteArray[2].should.endWith(relativeString2);
});
it("should return false if neither String nor Array", function () {
smartpath.absolute(3).should.be.false();
});
});
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsZ0RBQWdEO0FBQ2hELElBQUksTUFBTSxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQztBQUMvQixJQUFJLFNBQVMsR0FBRyxPQUFPLENBQUMsa0JBQWtCLENBQUMsQ0FBQztBQUU1QyxRQUFRLENBQUMsV0FBVyxFQUFDO0lBQ2pCLFFBQVEsQ0FBQyxZQUFZLEVBQUM7UUFDbEIsSUFBSSxVQUFVLEdBQUcsVUFBVSxDQUFBO1FBQzNCLElBQUksY0FBYyxHQUFHLHNCQUFzQixDQUFDO1FBQzVDLElBQUksZUFBZSxHQUFHLDRCQUE0QixDQUFDO1FBQ25ELElBQUksYUFBYSxHQUFHLENBQUMsY0FBYyxFQUFDLGNBQWMsRUFBQyxlQUFlLENBQUMsQ0FBQztRQUNwRSxFQUFFLENBQUMsK0JBQStCLEVBQUM7WUFDL0IsU0FBUyxDQUFDLFFBQVEsQ0FBQyxjQUFjLENBQUMsQ0FBQyxNQUFNLENBQUMsU0FBUyx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ob3VsZC5zdGFydFdpdGgoXCIvXCIpO1xuICAgICAgICAgICAgYWJzb2x1dGVBcnJheVsyXS5zaG91bGQuZW5kV2l0aChyZWxhdGl2ZVN0cmluZzIpO1xuXG4gICAgICAgIH0pXG4gICAgICAgIGl0KFwic2hvdWxkIHJldHVybiBmYWxzZSBpZiBuZWl0aGVyIFN0cmluZyBub3IgQXJyYXlcIixmdW5jdGlvbigpe1xuICAgICAgICAgICAgc21hcnRwYXRoLmFic29sdXRlKDMpLnNob3VsZC5iZS5mYWxzZSgpO1xuICAgICAgICB9KTtcbiAgICB9KVxufSk7XG4iXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=

1
test/test.js.map Normal file
View File

@ -0,0 +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,IAAI,UAAU,GAAG,UAAU,CAAA;QAC3B,IAAI,cAAc,GAAG,sBAAsB,CAAC;QAC5C,IAAI,eAAe,GAAG,4BAA4B,CAAC;QACnD,IAAI,aAAa,GAAG,CAAC,cAAc,EAAC,cAAc,EAAC,eAAe,CAAC,CAAC;QACpE,EAAE,CAAC,+BAA+B,EAAC;YAC/B,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YACzD,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;YAClE,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAC,UAAU,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;QAChG,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,uEAAuE,EAAC;YACvE,IAAI,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;YACtD,aAAa,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YACvC,aAAa,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;QAErD,CAAC,CAAC,CAAA;QACF,EAAE,CAAC,iDAAiD,EAAC;YACjD,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;QAC5C,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAC"}

26
test/test.ts Normal file
View File

@ -0,0 +1,26 @@
/// <reference path="../ts/typings/main.d.ts" />
let should = require("should");
let smartpath = require("../dist/index.js");
describe("smartpath",function(){
describe("absolute()",function(){
let baseString = "/basedir"
let relativeString = "somedir/somefile.txt";
let relativeString2 = "anotherdir/anotherfile.txt";
let relativeArray = [relativeString,relativeString,relativeString2];
it("should make a string absolute",function(){
smartpath.absolute(relativeString).should.startWith("/");
smartpath.absolute(relativeString).should.endWith(relativeString);
smartpath.absolute(relativeString,baseString).should.equal("/basedir/somedir/somefile.txt");
});
it("should make an array of relative Strings an Array of absolute Strings",function(){
let absoluteArray = smartpath.absolute(relativeArray);
absoluteArray[2].should.startWith("/");
absoluteArray[2].should.endWith(relativeString2);
})
it("should return false if neither String nor Array",function(){
smartpath.absolute(3).should.be.false();
});
})
});

View File

@ -8,8 +8,8 @@ import SmartpathAbsolute = require("./smartpath.absolute");
* @type {{getPath: (function(any): undefined)}}
*/
let smartpath = {
absolute: SmartpathAbsolute
};
module.exports = smartpath;
export = smartpath;

View File

@ -13,12 +13,12 @@ var makeAbsolute = function(localPathArg:string, baseArg?:string):string {
var absolute = function(relativeArg:any, baseArg?:string):any {
if(typeof relativeArg === "string"){
return makeAbsolute(relativeArg);
return makeAbsolute(relativeArg,baseArg);
} else if(Array.isArray(relativeArg)){
let relativeArray = relativeArg
let absoluteArray:string[];
let absoluteArray:string[] = [];
for (let key in relativeArray){
absoluteArray.push(makeAbsolute(relativeArray[key]));
absoluteArray.push(makeAbsolute(relativeArray[key],baseArg));
};
return absoluteArray;
} else {

View File

@ -1,5 +1,6 @@
{
"ambientDependencies": {
"mocha": "github:DefinitelyTyped/DefinitelyTyped/mocha/mocha.d.ts#d6dd320291705694ba8e1a79497a908e9f5e6617",
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#efa0c1196d7280640e624ac1e7fa604502e7bd63"
}
}