File tree Expand file tree Collapse file tree 5 files changed +10
-5
lines changed
packages/@angular/cli/blueprints Expand file tree Collapse file tree 5 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -222,7 +222,8 @@ export default Blueprint.extend({
222222 const className = stringUtils . classify ( `${ options . entity . name } Component` ) ;
223223 const fileName = stringUtils . dasherize ( `${ options . entity . name } .component` ) ;
224224 const componentDir = path . relative ( path . dirname ( this . pathToModule ) , this . generatePath ) ;
225- const importPath = componentDir ? `./${ componentDir } /${ fileName } ` : `./${ fileName } ` ;
225+ const normalizeRelativeDir = componentDir . startsWith ( '.' ) ? componentDir : `./${ componentDir } ` ;
226+ const importPath = componentDir ? `${ normalizeRelativeDir } /${ fileName } ` : `./${ fileName } ` ;
226227
227228 if ( ! options . skipImport ) {
228229 if ( options . dryRun ) {
Original file line number Diff line number Diff line change @@ -136,7 +136,8 @@ export default Blueprint.extend({
136136 const fullGeneratePath = path . join ( this . project . root , this . generatePath ) ;
137137 const moduleDir = path . parse ( this . pathToModule ) . dir ;
138138 const relativeDir = path . relative ( moduleDir , fullGeneratePath ) ;
139- const importPath = relativeDir ? `./${ relativeDir } /${ fileName } ` : `./${ fileName } ` ;
139+ const normalizeRelativeDir = relativeDir . startsWith ( '.' ) ? relativeDir : `./${ relativeDir } ` ;
140+ const importPath = relativeDir ? `${ normalizeRelativeDir } /${ fileName } ` : `./${ fileName } ` ;
140141
141142 if ( ! options . skipImport ) {
142143 if ( options . dryRun ) {
Original file line number Diff line number Diff line change @@ -103,7 +103,8 @@ export default Blueprint.extend({
103103 const fullGeneratePath = path . join ( this . project . root , this . generatePath ) ;
104104 const moduleDir = path . parse ( this . pathToModule ) . dir ;
105105 const relativeDir = path . relative ( moduleDir , fullGeneratePath ) ;
106- const importPath = relativeDir ? `./${ relativeDir } /${ fileName } ` : `./${ fileName } ` ;
106+ const normalizeRelativeDir = relativeDir . startsWith ( '.' ) ? relativeDir : `./${ relativeDir } ` ;
107+ const importPath = relativeDir ? `${ normalizeRelativeDir } /${ fileName } ` : `./${ fileName } ` ;
107108 returns . push (
108109 astUtils . addProviderToModule ( this . pathToModule , className , importPath )
109110 . then ( ( change : any ) => change . apply ( NodeHost ) ) ) ;
Original file line number Diff line number Diff line change @@ -121,7 +121,8 @@ export default Blueprint.extend({
121121 const fullGeneratePath = path . join ( this . project . root , this . generatePath ) ;
122122 const moduleDir = path . parse ( this . pathToModule ) . dir ;
123123 const relativeDir = path . relative ( moduleDir , fullGeneratePath ) ;
124- const importPath = relativeDir ? `./${ relativeDir } /${ fileName } ` : `./${ fileName } ` ;
124+ const normalizeRelativeDir = relativeDir . startsWith ( '.' ) ? relativeDir : `./${ relativeDir } ` ;
125+ const importPath = relativeDir ? `${ normalizeRelativeDir } /${ fileName } ` : `./${ fileName } ` ;
125126
126127 if ( ! options . skipImport ) {
127128 if ( options . dryRun ) {
Original file line number Diff line number Diff line change @@ -115,7 +115,8 @@ export default Blueprint.extend({
115115 const fullGeneratePath = path . join ( this . project . root , this . generatePath ) ;
116116 const moduleDir = path . parse ( this . pathToModule ) . dir ;
117117 const relativeDir = path . relative ( moduleDir , fullGeneratePath ) ;
118- const importPath = relativeDir ? `./${ relativeDir } /${ fileName } ` : `./${ fileName } ` ;
118+ const normalizeRelativeDir = relativeDir . startsWith ( '.' ) ? relativeDir : `./${ relativeDir } ` ;
119+ const importPath = relativeDir ? `${ normalizeRelativeDir } /${ fileName } ` : `./${ fileName } ` ;
119120 returns . push (
120121 astUtils . addProviderToModule ( this . pathToModule , className , importPath )
121122 . then ( ( change : any ) => change . apply ( NodeHost ) ) ) ;
You can’t perform that action at this time.
0 commit comments