File tree Expand file tree Collapse file tree 2 files changed +6
-7
lines changed
packages/schematics/angular/service-worker Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ function updateConfigFile(options: ServiceWorkerOptions, root: string): Rule {
6060
6161 const config = getProjectConfiguration ( workspace , options ) ;
6262 config . serviceWorker = true ;
63- config . ngswConfigPath = `${ root . endsWith ( '/' ) ? root : root + '/' } ngsw-config.json` ;
63+ config . ngswConfigPath = `${ root && ! root . endsWith ( '/' ) ? root + '/' : root } ngsw-config.json` ;
6464
6565 return updateWorkspace ( workspace ) ;
6666 } ;
@@ -174,17 +174,16 @@ export default function (options: ServiceWorkerOptions): Rule {
174174 resourcesOutputPath = '/' + resourcesOutputPath . split ( '/' ) . filter ( x => ! ! x ) . join ( '/' ) ;
175175 }
176176
177- const root = project . root || project . sourceRoot || '' ;
178177 const templateSource = apply ( url ( './files' ) , [
179178 applyTemplates ( { ...options , resourcesOutputPath } ) ,
180- move ( root ) ,
179+ move ( project . root ) ,
181180 ] ) ;
182181
183182 context . addTask ( new NodePackageInstallTask ( ) ) ;
184183
185184 return chain ( [
186185 mergeWith ( templateSource ) ,
187- updateConfigFile ( options , root ) ,
186+ updateConfigFile ( options , project . root ) ,
188187 addDependencies ( ) ,
189188 updateAppModule ( options ) ,
190189 ] ) ;
Original file line number Diff line number Diff line change @@ -120,7 +120,7 @@ describe('Service Worker Schematic', () => {
120120 . toContain ( '/outDir/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)' ) ;
121121 } ) ;
122122
123- it ( 'should generate ngsw-config.json in src when the application is at root level' , ( ) => {
123+ it ( 'should generate ngsw-config.json in root when the application is at root level' , ( ) => {
124124 const name = 'foo' ;
125125 const rootAppOptions : ApplicationOptions = {
126126 ...appOptions ,
@@ -134,11 +134,11 @@ describe('Service Worker Schematic', () => {
134134
135135 let tree = schematicRunner . runSchematic ( 'application' , rootAppOptions , appTree ) ;
136136 tree = schematicRunner . runSchematic ( 'service-worker' , rootSWOptions , tree ) ;
137- expect ( tree . exists ( '/src/ ngsw-config.json' ) ) . toBe ( true ) ;
137+ expect ( tree . exists ( '/ngsw-config.json' ) ) . toBe ( true ) ;
138138
139139 const { projects } = JSON . parse ( tree . readContent ( '/angular.json' ) ) ;
140140 expect ( projects . foo . architect . build . configurations . production . ngswConfigPath )
141- . toBe ( 'src/ ngsw-config.json' ) ;
141+ . toBe ( 'ngsw-config.json' ) ;
142142 } ) ;
143143
144144} ) ;
You can’t perform that action at this time.
0 commit comments