UNPKG

@nx-dotnet/utils

Version:

This library was generated with [Nx](https://nx.dev).

57 lines 2.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.projPattern = projPattern; exports.glob = glob; exports.globSync = globSync; exports.findProjectFileInPath = findProjectFileInPath; exports.findProjectFileInPathSync = findProjectFileInPathSync; const devkit_1 = require("@nx/devkit"); const fg = require("fast-glob"); const path_1 = require("path"); const globOptions = { cwd: devkit_1.workspaceRoot, ignore: ['**/bin/**', '**/obj/**'], dot: true, }; function projPattern(path) { return `${path}/**/*.@(cs|fs|vb|sql)proj`; } /** * Wraps the fast-glob package. * @returns array of file paths */ function glob(path, cwd, tree) { if (tree) { return (0, devkit_1.glob)(tree, [path]); } return fg(path, !cwd ? globOptions : { ...globOptions, cwd: (0, path_1.join)(devkit_1.workspaceRoot, cwd) }); } function globSync(path, cwd, tree) { if (tree) { return (0, devkit_1.glob)(tree, [path]); } return fg.sync(path, !cwd ? globOptions : { ...globOptions, cwd: (0, path_1.join)(devkit_1.workspaceRoot, cwd) }); } async function findProjectFileInPath(path, tree) { const results = await glob(projPattern(path), undefined, tree); if (!results || results.length === 0) { throw new Error(`Unable to find a build-able project within project's source directory! - Looked in: ${path}`); } if (results.length > 1) { throw new Error(`More than one build-able projects are contained within the project's source directory! \r\n ${results.join(', \r\n')}`); } return results[0]; } function findProjectFileInPathSync(path, tree) { const results = globSync(projPattern(path), undefined, tree); if (!results || results.length === 0) { throw new Error(`Unable to find a build-able project within project's source directory! - Looked in: ${path}`); } if (results.length > 1) { throw new Error(`More than one build-able projects are contained within the project's source directory! \r\n ${results.join(', \r\n')}`); } return results[0]; } //# sourceMappingURL=glob.js.map