UNPKG

1.39 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var fs_extra_1 = require("fs-extra");
4var path_1 = require("path");
5var Project = (function () {
6 function Project(paths) {
7 this.paths = paths;
8 this.isRails = fs_extra_1.existsSync(path_1.join(paths.app.root, 'Gemfile'));
9 this.isTypeScript = fs_extra_1.existsSync(path_1.join(paths.app.root, 'tsconfig.json'));
10 }
11 Object.defineProperty(Project.prototype, "packageJSON", {
12 get: function () {
13 if (this.cachedPackageJSON == null) {
14 try {
15 this.cachedPackageJSON = fs_extra_1.readJSONSync(path_1.join(this.paths.app.packageJSON));
16 }
17 catch (error) {
18 this.cachedPackageJSON = {};
19 }
20 }
21 return this.cachedPackageJSON;
22 },
23 enumerable: true,
24 configurable: true
25 });
26 Project.prototype.hasDependency = function (dependency) {
27 var packageJSON = this.packageJSON;
28 return packageJSON.dependencies != null && packageJSON.dependencies[dependency] != null;
29 };
30 Project.prototype.ifRails = function (then, or) { return this.isRails ? then : or; };
31 Project.prototype.ifTypeScript = function (then, or) { return this.isTypeScript ? then : or; };
32 return Project;
33}());
34exports.default = Project;