add getName function

This commit is contained in:
Philipp Kunz 2016-02-20 06:06:43 +01:00
parent 841c8aa114
commit 77e473fe81
7 changed files with 39 additions and 6 deletions

10
dist/index.js vendored
View File

@ -1,9 +1,17 @@
//import classes //import classes
var ProjectinfoNPM = require("./projectinfo.npm"); var ProjectinfoNPM = require("./projectinfo.npm");
var projectinfo = {}; var projectinfo = {};
//specific classes
projectinfo.npm = function (cwdArg) { projectinfo.npm = function (cwdArg) {
return new ProjectinfoNPM(cwdArg); return new ProjectinfoNPM(cwdArg);
}; };
//quick functions
projectinfo.getName = function (cwdArg) {
var localNpm = projectinfo.npm(cwdArg);
if (localNpm.status === "ok") {
return localNpm.name;
}
};
module.exports = projectinfo; module.exports = projectinfo;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUdBLGdCQUFnQjtBQUNoQixJQUFPLGNBQWMsV0FBVyxtQkFBbUIsQ0FBQyxDQUFDO0FBRXJELElBQUksV0FBVyxHQUFPLEVBQUUsQ0FBQztBQUV6QixXQUFXLENBQUMsR0FBRyxHQUFHLFVBQVMsTUFBTTtJQUM3QixNQUFNLENBQUMsSUFBSSxjQUFjLENBQUMsTUFBTSxDQUFDLENBQUM7QUFDdEMsQ0FBQyxDQUFDO0FBWUYsaUJBQVMsV0FBVyxDQUFDIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxuaW1wb3J0IHBsdWdpbnMgPSByZXF1aXJlKFwiLi9wcm9qZWN0aW5mby5wbHVnaW5zXCIpO1xuXG4vL2ltcG9ydCBjbGFzc2VzXG5pbXBvcnQgUHJvamVjdGluZm9OUE0gPSByZXF1aXJlKFwiLi9wcm9qZWN0aW5mby5ucG1cIik7XG5cbnZhciBwcm9qZWN0aW5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DxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxuaW1wb3J0IHBsdWdpbnMgPSByZXF1aXJlKFwiLi9wcm9qZWN0aW5mby5wbHVnaW5zXCIpO1xuXG4vL2ltcG9ydCBjbGFzc2VzXG5pbXBvcnQgUHJvamVjdGluZm9OUE0gPSByZXF1aXJlKFwiLi9wcm9qZWN0aW5mby5ucG1cIik7XG5cbnZhciBwcm9qZWN0aW5mbzphbnkgPSB7fTtcblxuLy9zcGVjaWZpYyBjbGFzc2VzXG5wcm9qZWN0aW5mby5ucG0gPSBmdW5jdGlvbihjd2RBcmcpe1xuICAgIHJldHVybiBuZXcgUHJvamVjdGluZm9OUE0oY3dkQXJnKTtcbn07XG5cbi8vcXVpY2sgZnVuY3Rpb25zXG5wcm9qZWN0aW5mby5nZXROYW1lID0gZnVuY3Rpb24oY3dkQXJnKXtcbiAgICB2YXIgbG9jYWxOcG0gPSBwcm9qZWN0aW5mby5ucG0oY3dkQXJnKTtcbiAgICBpZiAobG9jYWxOcG0uc3RhdHVzID09PSBcIm9rXCIpe1xuICAgICAgICByZXR1cm4gbG9jYWxOcG0ubmFtZTtcbiAgICB9XG59O1xuXG4vKiBUT0RPXG5wcm9qZWN0aW5mby5naXQgPSBmdW5jdGlvbigpe1xuXG59O1xuXG5wcm9qZWN0aW5mby5tb2pvID0gZnVuY3Rpb24oKXtcblxufTtcbiovXG5cbmV4cG9ydCA9IHByb2plY3RpbmZvOyJdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==

View File

@ -5,9 +5,10 @@ var ProjectinfoNPM = (function () {
this.packageJson = plugins.smartfile.readFileToObject(plugins.path.join(plugins.path.resolve(cwdArg), "package.json")); this.packageJson = plugins.smartfile.readFileToObject(plugins.path.join(plugins.path.resolve(cwdArg), "package.json"));
this.name = this.packageJson.name; this.name = this.packageJson.name;
this.version = this.packageJson.version; this.version = this.packageJson.version;
this.status = "ok";
} }
return ProjectinfoNPM;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N0aW5mby5wbHVnaW5zXCIpO1xuY2xhc3MgUHJvamVjdGluZm9OUE0gIHtcbiAgICBwYWNrYWdlSnNvbjtcbiAgICBuYW1lOnN0cmluZztcbiAgICB2ZXJzaW9uOnN0cmluZztcblxuICAgIGNvbnN0cnVjdG9yKGN3ZEFyZyl7XG4gICAgICAgIHRoaXMucGFja2FnZUpzb24gPSBwbHVnaW5zLnNtYXJ0ZmlsZS5yZWFkRmlsZVRvT2JqZWN0KFxuICAgICAgICAgICAgcGx1Z2lucy5wYXRoLmpvaW4oXG4gICAgICAgICAgICAgICAgcGx1Z2lucy5wYXRoLnJlc29sdmUoY3dkQXJnKSxcbiAgICAgICAgICAgICAgICBcInBhY2thZ2UuanNvblwiXG4gICAgICAgICAgICApXG4gICAgICAgICk7XG4gICAgICAgIHRoaXMubmFtZSA9IHRoaXMucGFja2FnZUpzb24ubmFtZTtcbiAgICAgICAgdGhpcy52ZXJzaW9uID0gdGhpcy5wYWNrYWdlSnNvbi52ZXJzaW9uO1xuICAgIH1cbn1cblxuZXhwb3J0ID0gUHJvamVjdGluZm9OUE07Il0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9 //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInByb2plY3RpbmZvLm5wbS50cyJdLCJuYW1lcyI6WyJQcm9qZWN0aW5mb05QTSIsIlByb2plY3RpbmZvTlBNLmNvbnN0cnVjdG9yIl0sIm1hcHBpbmdzIjoiQUFBQSw0Q0FBNEM7QUFDNUMsSUFBTyxPQUFPLFdBQVcsdUJBQXVCLENBQUMsQ0FBQztBQUNsRDtJQU1JQSx3QkFBWUEsTUFBYUE7UUFDckJDLElBQUlBLENBQUNBLFdBQVdBLEdBQUdBLE9BQU9BLENBQUNBLFNBQVNBLENBQUNBLGdCQUFnQkEsQ0FDakRBLE9BQU9BLENBQUNBLElBQUlBLENBQUNBLElBQUlBLENBQ2JBLE9BQU9BLENBQUNBLElBQUlBLENBQU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gPSB0aGlzLnBhY2thZ2VKc29uLm5hbWU7XG4gICAgICAgIHRoaXMudmVyc2lvbiA9IHRoaXMucGFja2FnZUpzb24udmVyc2lvbjtcbiAgICAgICAgdGhpcy5zdGF0dXMgPSBcIm9rXCI7XG4gICAgfVxufVxuXG5leHBvcnQgPSBQcm9qZWN0aW5mb05QTTsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=

View File

@ -21,6 +21,12 @@ describe("projectinfo", function () {
.should.have.property("name", "testpackage"); .should.have.property("name", "testpackage");
}); });
}); });
describe(".getName()", function () {
it("should return a name", function () {
projectinfo.getName(testBasePath)
.should.equal("testpackage");
});
});
}); });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsZ0RBQWdEO0FBQ2hELElBQUksV0FBVyxHQUFHLE9BQU8sQ0FBQyxrQkFBa0IsQ0FBQyxDQUFDO0FBQzlDLElBQUksTUFBTSxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQztBQUMvQixJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLENBQUM7QUFDM0IsSUFBSSxZQUFZLEdBQUcsSUFBSSxDQUFDLE9BQU8sQ0FBQyxTQUFTLENBQUMsQ0FBQztBQUUzQyxRQUFRLENBQUMsYUFBYSxFQUFDO0lBQ25CLFFBQVEsQ0FBQyxlQUFlLEVBQUM7UUFDckIsSUFBSSxLQUFLLEdBQUcsV0FBVyxDQUFDLEdBQUcsQ0FBQyxZQUFZLENBQUMsQ0FBQztRQUMxQyxFQUFFLENBQUMsMEJBQTBCLEVBQUM7WUFDMUIsS0FBSyxDQUFDLFdBQVc7aUJBQ2IsTUFBTSxDQUFDLElBQUksQ0FBQyxRQUFRLENBQUMsU0FBUyxFQUFDLE9BQU8sQ0FBQyxDQUFDO1lBQzVDLEtBQUssQ0FBQyxXQUF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lc3QuanMiLCJzb3VyY2VzQ29udGVudCI6WyIvLy8gPHJlZmVyZW5jZSBwYXRoPVwiLi4vdHMvdHlwaW5ncy9tYWluLmQudHNcIiAvPlxudmFyIHByb2plY3RpbmZvID0gcmVxdWlyZShcIi4uL2Rpc3QvaW5kZXguanNcIik7XG52YXIgc2hvdWxkID0gcmVxdWlyZShcInNob3VsZFwiKTtcbnZhciBwYXRoID0gcmVxdWlyZShcInBhdGhcIik7XG52YXIgdGVzdEJhc2VQYXRoID0gcGF0aC5yZXNvbHZlKF9fZGlybmFtZSk7XG5cbmRlc2NyaWJlKFwicHJvamVjdGluZm9cIixmdW5jdGlvbigpe1xuICAgIGRlc2NyaWJlKFwiLm5wbSgpIHJldHVyblwiLGZ1bmN0aW9uKCl7XG4gICAgICAgIHZhciBteU5wbSA9IHByb2plY3RpbmZvLm5wbSh0ZXN0QmFzZVBhdGgpO1xuICAgICAgICBpdChcInNob3VsZCBoYXZlIC5wYWNrYWdlSnNvblwiLGZ1bmN0aW9uKCl7XG4gICAgICAgICAgICBteU5wbS5wYWNrYWdlSnNvblxuICAgICAgICAgICAgICAgLnNob3VsZC5oYXZlLnByb3BlcnR5KFwidmVyc2lvblwiLFwiMS4wLjBcIik7XG4gICAgICAgICAgICBteU5wbS5wYWNrYWdlSnNvblxuICAgICAgICAgICAgICAgLnNob3VsZC5oYXZlLnByb3BlcnR5KFwibmFtZVwiLFwidGVzdHBhY2thZ2VcIik7XG4gICAgICAgIH0pO1xuXG4gICAgICAgIGl0KFwic2hvdWxkIGhhdmUgLnZlcnNpb25cIixmdW5jdGlvbigpe1xuICAgICAgICAgICAgbXlOcG1cbiAgICAgICAgICAgICAgICAuc2hvdWxkLmhhdmUucHJvcGVydHkoXCJuYW1lXCIsXCJ0ZXN0cGFja2FnZVwiKVxuICAgICAgICB9KTtcblxuICAgICAgICBpdChcInNob3VsZCBoYXZlIC5uYW1lXCIsZnVuY3Rpb24oKXtcbiAgICAgICAgICAgIG15TnBtXG4gICA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D,CAAC,CAAC,CAAC;IAEP,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,YAAY,EAAC;QAClB,EAAE,CAAC,sBAAsB,EAAC;YACtB,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC;iBAC5B,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAC"}

View File

@ -22,7 +22,14 @@ describe("projectinfo",function(){
it("should have .name",function(){ it("should have .name",function(){
myNpm myNpm
.should.have.property("name","testpackage"); .should.have.property("name","testpackage");
}) });
}); });
describe(".getName()",function(){
it("should return a name",function(){
projectinfo.getName(testBasePath)
.should.equal("testpackage");
});
})
}); });

View File

@ -6,10 +6,19 @@ import ProjectinfoNPM = require("./projectinfo.npm");
var projectinfo:any = {}; var projectinfo:any = {};
//specific classes
projectinfo.npm = function(cwdArg){ projectinfo.npm = function(cwdArg){
return new ProjectinfoNPM(cwdArg); return new ProjectinfoNPM(cwdArg);
}; };
//quick functions
projectinfo.getName = function(cwdArg){
var localNpm = projectinfo.npm(cwdArg);
if (localNpm.status === "ok"){
return localNpm.name;
}
};
/* TODO /* TODO
projectinfo.git = function(){ projectinfo.git = function(){

View File

@ -4,8 +4,9 @@ class ProjectinfoNPM {
packageJson; packageJson;
name:string; name:string;
version:string; version:string;
status:string;
constructor(cwdArg){ constructor(cwdArg:string){
this.packageJson = plugins.smartfile.readFileToObject( this.packageJson = plugins.smartfile.readFileToObject(
plugins.path.join( plugins.path.join(
plugins.path.resolve(cwdArg), plugins.path.resolve(cwdArg),
@ -14,6 +15,7 @@ class ProjectinfoNPM {
); );
this.name = this.packageJson.name; this.name = this.packageJson.name;
this.version = this.packageJson.version; this.version = this.packageJson.version;
this.status = "ok";
} }
} }