1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.isInRootDirectory = isInRootDirectory;
|
4 | exports.mergeSourceRoot = mergeSourceRoot;
|
5 | const core_1 = require("@angular-devkit/core");
|
6 | const defaults_1 = require("../lib/defaults");
|
7 | function isInRootDirectory(host, extraFiles = []) {
|
8 | const files = ['nest-cli.json', 'nest.json'].concat(extraFiles || []);
|
9 | return files.map(file => host.exists(file)).some(isPresent => isPresent);
|
10 | }
|
11 | function mergeSourceRoot(options) {
|
12 | return (host) => {
|
13 | const isInRoot = isInRootDirectory(host, ['tsconfig.json', 'package.json']);
|
14 | if (!isInRoot) {
|
15 | return host;
|
16 | }
|
17 | const defaultSourceRoot = options.sourceRoot !== undefined ? options.sourceRoot : defaults_1.DEFAULT_PATH_NAME;
|
18 | options.path =
|
19 | options.path !== undefined
|
20 | ? (0, core_1.join)((0, core_1.normalize)(defaultSourceRoot), options.path)
|
21 | : (0, core_1.normalize)(defaultSourceRoot);
|
22 | return host;
|
23 | };
|
24 | }
|