Skip to content

build: secondary entry-points resolving for windows #6652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions tools/package-tools/secondary-entry-points.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {join} from 'path';
import {readdirSync, lstatSync, existsSync} from 'fs';
import {spawnSync} from 'child_process';
import {BuildPackage} from './build-package';
import {platform} from 'os';


/**
Expand Down Expand Up @@ -36,14 +37,12 @@ export function getSecondaryEntryPointsForPackage(pkg: BuildPackage) {

// Update the deps for each node to point to the appropriate BuildNodes.
buildNodes.forEach(node => {
const importStatementFindCommand = buildPackageImportStatementFindCommand(
join(packageDir, node.name), packageName);

// Look for any imports that reference this same umbrella package and get the corresponding
// BuildNode for each by looking at the import statements with grep.
node.deps = spawnSync('grep', [
'-Eroh',
'--include', '*.ts',
`from '@angular/${packageName}/.+';`,
`${packageDir}/${node.name}/`
])
node.deps = spawnSync(importStatementFindCommand.binary, importStatementFindCommand.args)
.stdout
.toString()
.split('\n')
Expand Down Expand Up @@ -86,3 +85,19 @@ interface BuildNode {
deps: BuildNode[];
visited?: boolean;
}


/** Builds the command that will be executed to find all import statements for a package. */
function buildPackageImportStatementFindCommand(searchDirectory: string, packageName: string) {
if (platform() === 'win32') {
return {
binary: 'findstr',
args: ['/r', `from.'@angular/${packageName}/.*'`, `${searchDirectory}\\*`]
};
} else {
return {
binary: 'grep',
args: ['-Eroh', '--include', '*.ts', `from '@angular/${packageName}/.+';`, searchDirectory]
};
}
}