File tree 5 files changed +10
-5
lines changed
packages/@angular/cli/blueprints
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({
222
222
const className = stringUtils . classify ( `${ options . entity . name } Component` ) ;
223
223
const fileName = stringUtils . dasherize ( `${ options . entity . name } .component` ) ;
224
224
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 } ` ;
226
227
227
228
if ( ! options . skipImport ) {
228
229
if ( options . dryRun ) {
Original file line number Diff line number Diff line change @@ -136,7 +136,8 @@ export default Blueprint.extend({
136
136
const fullGeneratePath = path . join ( this . project . root , this . generatePath ) ;
137
137
const moduleDir = path . parse ( this . pathToModule ) . dir ;
138
138
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 } ` ;
140
141
141
142
if ( ! options . skipImport ) {
142
143
if ( options . dryRun ) {
Original file line number Diff line number Diff line change @@ -103,7 +103,8 @@ export default Blueprint.extend({
103
103
const fullGeneratePath = path . join ( this . project . root , this . generatePath ) ;
104
104
const moduleDir = path . parse ( this . pathToModule ) . dir ;
105
105
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 } ` ;
107
108
returns . push (
108
109
astUtils . addProviderToModule ( this . pathToModule , className , importPath )
109
110
. then ( ( change : any ) => change . apply ( NodeHost ) ) ) ;
Original file line number Diff line number Diff line change @@ -121,7 +121,8 @@ export default Blueprint.extend({
121
121
const fullGeneratePath = path . join ( this . project . root , this . generatePath ) ;
122
122
const moduleDir = path . parse ( this . pathToModule ) . dir ;
123
123
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 } ` ;
125
126
126
127
if ( ! options . skipImport ) {
127
128
if ( options . dryRun ) {
Original file line number Diff line number Diff line change @@ -115,7 +115,8 @@ export default Blueprint.extend({
115
115
const fullGeneratePath = path . join ( this . project . root , this . generatePath ) ;
116
116
const moduleDir = path . parse ( this . pathToModule ) . dir ;
117
117
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 } ` ;
119
120
returns . push (
120
121
astUtils . addProviderToModule ( this . pathToModule , className , importPath )
121
122
. then ( ( change : any ) => change . apply ( NodeHost ) ) ) ;
You can’t perform that action at this time.
0 commit comments