clasp-types
Version:
A d.ts generator for clasp projects
45 lines (44 loc) • 2.87 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.LicenseBuilder = void 0;
var Builder_1 = require("./Builder");
var LicenseBuilder = /** @class */ (function (_super) {
__extends(LicenseBuilder, _super);
function LicenseBuilder(packageJson) {
var _this = _super.call(this) || this;
_this.packageJson = packageJson;
return _this;
}
LicenseBuilder.prototype.build = function () {
var date = new Date().toLocaleDateString("en-US", { year: 'numeric' });
this
.append("\nMIT License\n\nCopyright (c) " + date + " " + this.extractAuthor() + "\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n ").doubleLine();
return this;
};
LicenseBuilder.prototype.extractAuthor = function () {
if (this.packageJson.author) {
if (typeof this.packageJson.author === 'string') {
return this.packageJson.author;
}
else {
return (this.packageJson.author.name ? this.packageJson.author.name : '') + " " + (this.packageJson.author.email ? this.packageJson.author.email : '');
}
}
return '';
};
return LicenseBuilder;
}(Builder_1.Builder));
exports.LicenseBuilder = LicenseBuilder;