From 950edccbc4fdd7b61278629f2bb9b3b1016aff73 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Wed, 30 Aug 2017 04:41:15 +0200 Subject: [PATCH] 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. --- tools/gulp/tasks/examples.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/gulp/tasks/examples.ts b/tools/gulp/tasks/examples.ts index 716292abe99..b8384647cc3 100644 --- a/tools/gulp/tasks/examples.ts +++ b/tools/gulp/tasks/examples.ts @@ -34,15 +34,15 @@ const examplesPath = path.join(packagesDir, 'material-examples'); /** Output path of the module that is being created */ const outputModuleFilename = path.join(examplesPath, 'example-module.ts'); -/** Build ES module import statements */ +/** Build ES module import statements for the examples. */ function buildImportsTemplate(metadata: ExampleMetadata): string { const components = metadata.additionalComponents.concat(metadata.component); // Create a relative path to the source file of the current example. // The relative path will be used inside of a TypeScript import statement. const relativeSrcPath = path - .relative('./src/material-examples', metadata.sourcePath) - .replace(/\\/g, '') + .relative(examplesPath, metadata.sourcePath) + .replace(/\\/g, '/') .replace('.ts', ''); return `import {${components.join(',')}} from './${relativeSrcPath}'; @@ -195,8 +195,8 @@ function parseExampleMetadata(fileName: string, sourceContent: string): ParsedMe */ task('build-examples-module', () => { const results: ExampleMetadata[] = []; - const matchedFiles = glob(path.join(examplesPath, '**/*.ts')); + for (const sourcePath of matchedFiles) { const sourceContent = fs.readFileSync(sourcePath, 'utf-8'); const { primaryComponent, secondaryComponents } =