Skip to content

Commit

Permalink
fix(core): make globPatternforDependencies support nx:run-commands wi…
Browse files Browse the repository at this point in the history
…th cwd option

As globPatternforDependencies expects cwd to be in workspaceRoot, it will fail if it's used in a
script that is called via nx:run-commands with `cwd` option pointing to project. This \"fix\" changes
the process cwd to workspaceRoot while running the globPatternforDependencies script, then changes
back.

ISSUES CLOSED: #12721
  • Loading branch information
ViktorPontinen committed Oct 26, 2022
1 parent b20c309 commit 711cfb3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/workspace/src/utilities/generate-globs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,16 @@ export function createGlobPatternsForDependencies(

const dirsToUse = [];
const recursiveScanDirs = (dirPath) => {
const children = readdirSync(dirPath);
const children = readdirSync(resolve(workspaceRoot, dirPath));
for (const child of children) {
const childPath = join(dirPath, child);
if (ig?.ignores(childPath) || !lstatSync(childPath).isDirectory()) {
if (
ig?.ignores(childPath) ||
!lstatSync(resolve(workspaceRoot, childPath)).isDirectory()
) {
continue;
}
if (existsSync(join(childPath, 'ng-package.json'))) {
if (existsSync(join(workspaceRoot, childPath, 'ng-package.json'))) {
dirsToUse.push(childPath);
} else {
recursiveScanDirs(childPath);
Expand Down

0 comments on commit 711cfb3

Please sign in to comment.