Skip to content

Commit 950edcc

Browse files
devversionjelbourn
authored andcommitted
build: invalid paths when building examples module (#6673)
On Windows, if someone runs the `gulp build-examples-module` task, the `example-module.ts` file will be generated incorrectly. Path delimiters are missing in the TypeScript imports because the Windows path delimiters are being removed accidentally.
1 parent 2b74755 commit 950edcc

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tools/gulp/tasks/examples.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ const examplesPath = path.join(packagesDir, 'material-examples');
3434
/** Output path of the module that is being created */
3535
const outputModuleFilename = path.join(examplesPath, 'example-module.ts');
3636

37-
/** Build ES module import statements */
37+
/** Build ES module import statements for the examples. */
3838
function buildImportsTemplate(metadata: ExampleMetadata): string {
3939
const components = metadata.additionalComponents.concat(metadata.component);
4040

4141
// Create a relative path to the source file of the current example.
4242
// The relative path will be used inside of a TypeScript import statement.
4343
const relativeSrcPath = path
44-
.relative('./src/material-examples', metadata.sourcePath)
45-
.replace(/\\/g, '')
44+
.relative(examplesPath, metadata.sourcePath)
45+
.replace(/\\/g, '/')
4646
.replace('.ts', '');
4747

4848
return `import {${components.join(',')}} from './${relativeSrcPath}';
@@ -195,8 +195,8 @@ function parseExampleMetadata(fileName: string, sourceContent: string): ParsedMe
195195
*/
196196
task('build-examples-module', () => {
197197
const results: ExampleMetadata[] = [];
198-
199198
const matchedFiles = glob(path.join(examplesPath, '**/*.ts'));
199+
200200
for (const sourcePath of matchedFiles) {
201201
const sourceContent = fs.readFileSync(sourcePath, 'utf-8');
202202
const { primaryComponent, secondaryComponents } =

0 commit comments

Comments
 (0)