Skip to content

Commit

Permalink
fix(scripts/generators): make sure to flush nx Tree outside nx contex…
Browse files Browse the repository at this point in the history
…t in order to write changes on physical file system (#28396)
  • Loading branch information
Hotell authored Jun 30, 2023
1 parent 1745a0b commit 2d874b5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion scripts/generators/create-package/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { spawnSync } from 'child_process';
import * as path from 'path';

import { PackageJson, findGitRoot, getProjectMetadata, tree } from '@fluentui/scripts-monorepo';
import { PackageJson, findGitRoot, flushTreeChanges, getProjectMetadata, tree } from '@fluentui/scripts-monorepo';
import { addProjectConfiguration } from '@nrwl/devkit';
import chalk from 'chalk';
import * as fs from 'fs-extra';
Expand Down Expand Up @@ -295,4 +295,6 @@ function updateNxProject(_answers: Answers, config: { projectName: string; proje
projectType: 'library',
implicitDependencies: [],
});

flushTreeChanges();
}
2 changes: 1 addition & 1 deletion scripts/monorepo/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export { getDefaultEnvironmentVars } from './getDefaultEnvironmentVars';
export { getProjectMetadata, workspaceRoot, getUncommittedFiles, getUntrackedFiles } from './utils';
export * as eslintConstants from './eslint-constants';
export { getNthCommit } from './getNthCommit';
export { tree } from './tree';
export { tree, flushTreeChanges } from './tree';
4 changes: 3 additions & 1 deletion scripts/monorepo/src/tree.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const { workspaceRoot } = require('@nrwl/devkit');
const { FsTree } = require('nx/src/generators/tree');
const { FsTree, flushChanges } = require('nx/src/generators/tree');

const tree = new FsTree(workspaceRoot, false);

exports.flushTreeChanges = () => flushChanges(workspaceRoot, tree.listChanges());
exports.tree = tree;

0 comments on commit 2d874b5

Please sign in to comment.