Skip to content

Commit

Permalink
nest-webpack.js monorepoRoot use config from tsdk.config.js
Browse files Browse the repository at this point in the history
  • Loading branch information
suhaotian committed Jan 2, 2024
1 parent 6d1a932 commit e7e2eca
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
4 changes: 3 additions & 1 deletion packages/tsdk/src/nest-webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import nodeExternals from 'webpack-node-externals';

import { getNpmCommand } from './get-pkg-manager';

export const tsdkConfigFilePath = path.join(process.cwd(), 'tsdk.config.js');

const defaultMainName = 'default';
const distProjects = 'dist-projects';

Expand Down Expand Up @@ -191,7 +193,7 @@ async function getNestProjectsConfig() {
const cwd = process.cwd();
const nestjsFilepath = path.resolve(
cwd,
process.env.MONOREPO_ROOT || './',
require(tsdkConfigFilePath).monorepoRoot || './',
'node_modules/@nestjs/cli/package.json'
);
const nestjsFilepathExists = await fsExtra.pathExists(nestjsFilepath);
Expand Down
21 changes: 12 additions & 9 deletions packages/tsdk/src/run-nest-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@ export async function runNestCommand() {
if (command === 'build') {
const cwd = process.cwd();
const webpackDistFile = path.resolve(cwd, 'node_modules', 'nest-webpack.js');
const pkgManagerDistFile = path.resolve(cwd, 'node_modules', 'get-pkg-manager.js');
await Promise.all([
fsExtra.copy(path.resolve(__dirname, '../lib/nest-webpack.js'), webpackDistFile, {
overwrite: true,
}),
fsExtra.copy(path.resolve(__dirname, '../lib/get-pkg-manager.js'), pkgManagerDistFile, {
overwrite: true,
}),
]);
const copyFiles = ['nest-webpack.js', 'get-pkg-manager.js'];
await Promise.all(
copyFiles.map((filename) => {
return fsExtra.copy(
path.resolve(__dirname, `../lib/${filename}`),
path.resolve(cwd, 'node_modules', filename),
{
overwrite: true,
}
);
})
);

const names = process.argv.filter((i, index) => index > idx + 1);

Expand Down

0 comments on commit e7e2eca

Please sign in to comment.