Skip to content

Commit

Permalink
Fixed the license method
Browse files Browse the repository at this point in the history
  • Loading branch information
IonicaBizau committed Jun 7, 2015
1 parent 9b614f2 commit 4d9059f
Showing 1 changed file with 39 additions and 54 deletions.
93 changes: 39 additions & 54 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ Blah.prototype.prepare = function (callback) {
], function (err, data) {
if (err) { return callback(err); }
self.pack = data[0];
self.copyright = {
fullname: self.pack.author
, year: new Date().getFullYear()
, project: self.pack.name
, description: self.pack.description
};
callback();
});
});
Expand Down Expand Up @@ -234,61 +240,40 @@ Blah.prototype.readme = function (callback) {
* @function
* @return {String} Content of gitignore file.
*/
Blah.prototype.generateGitignore = function () {

var content =
"*.swp\n" +
"*.swo\n" +
"*~\n" +
"*.log\n" +
"node_modules"
;
Blah.prototype.gitignore = function (callback) {
var self = this;
self.prepare(function (err) {
if (err) { return callback(err); }
Ncp(self.paths.gitignore, ".gitignore", callback);
});
};

return content;
/**
* generateLicense
* Returns the content of the LICENSE by providing the `@licenseName`.
*
* @name generateLicense
* @function
* @param {String} licenseName The license name (e.g. `mit`)
* @return {String} The content of license.
*/
Blah.prototype.license = function (license, callback) {
var self = this;
self.prepare(function (err) {
if (err) { return callback(err); }
var licensePath = __dirname + "/licenses/" + license.toLowerCase() + ".txt";
if (!IsThere(licensePath)) {
return callback(new Error("There is no license named " + license));
}
if (!self.copyright.fullname) {
return callback(new Error("Cannot find the author name. Is the package.json file missing?"));
}
Fs.readFile(licensePath, "utf-8", function (err, content) {
if (err) { return callback(err); }
content = Barbe(content, ["[", "]"], self.copyright);
Fs.writeFile("LICENSE", content, callback);
});
});
};
//
///**
// * generateLicense
// * Returns the content of the LICENSE by providing the `@licenseName`.
// *
// * @name generateLicense
// * @function
// * @param {String} licenseName The license name (e.g. `mit`)
// * @return {String} The content of license.
// */
//Blah.prototype.generateLicense = function (licenseName) {
//
// var fullName = null
// , pack = require(process.env.PWD + "/package")
// ;
//
// try {
// var gitconfigLines = Fs.readFileSync(
// require('path-extra').homedir() + "/.gitconfig"
// ).toString().replace(/\t/g, "").split("\n");
// for (var i = 0; i < gitconfigLines.length; ++i) {
// var cLine = gitconfigLines[i].trim();
// if (/^name/.test(cLine)) {
// fullName = cLine.split("=")[1].trim();
// break;
// }
// }
// } catch(e) {
// }
//
// if (!fullName) {
// console.log("No fullname found in .gitconfig. Please modify LICENSE [fullname] manually");
// fullName = "[fullname]";
// }
//
// return Fs
// .readFileSync(__dirname + "/templates/licenses/" + licenseName.toLowerCase() + ".txt")
// .toString()
// .replace("[project]", pack.name)
// .replace("[year]", new Date().getFullYear())
// .replace("[fullname]", fullName)
// .replace("[description]", pack.description)
// ;
//};

module.exports = Blah;

0 comments on commit 4d9059f

Please sign in to comment.