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 {
60
60
61
61
const config = getProjectConfiguration ( workspace , options ) ;
62
62
config . serviceWorker = true ;
63
- config . ngswConfigPath = `${ root . endsWith ( '/' ) ? root : root + '/' } ngsw-config.json` ;
63
+ config . ngswConfigPath = `${ root && ! root . endsWith ( '/' ) ? root + '/' : root } ngsw-config.json` ;
64
64
65
65
return updateWorkspace ( workspace ) ;
66
66
} ;
@@ -174,17 +174,16 @@ export default function (options: ServiceWorkerOptions): Rule {
174
174
resourcesOutputPath = '/' + resourcesOutputPath . split ( '/' ) . filter ( x => ! ! x ) . join ( '/' ) ;
175
175
}
176
176
177
- const root = project . root || project . sourceRoot || '' ;
178
177
const templateSource = apply ( url ( './files' ) , [
179
178
applyTemplates ( { ...options , resourcesOutputPath } ) ,
180
- move ( root ) ,
179
+ move ( project . root ) ,
181
180
] ) ;
182
181
183
182
context . addTask ( new NodePackageInstallTask ( ) ) ;
184
183
185
184
return chain ( [
186
185
mergeWith ( templateSource ) ,
187
- updateConfigFile ( options , root ) ,
186
+ updateConfigFile ( options , project . root ) ,
188
187
addDependencies ( ) ,
189
188
updateAppModule ( options ) ,
190
189
] ) ;
Original file line number Diff line number Diff line change @@ -120,7 +120,7 @@ describe('Service Worker Schematic', () => {
120
120
. toContain ( '/outDir/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)' ) ;
121
121
} ) ;
122
122
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' , ( ) => {
124
124
const name = 'foo' ;
125
125
const rootAppOptions : ApplicationOptions = {
126
126
...appOptions ,
@@ -134,11 +134,11 @@ describe('Service Worker Schematic', () => {
134
134
135
135
let tree = schematicRunner . runSchematic ( 'application' , rootAppOptions , appTree ) ;
136
136
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 ) ;
138
138
139
139
const { projects } = JSON . parse ( tree . readContent ( '/angular.json' ) ) ;
140
140
expect ( projects . foo . architect . build . configurations . production . ngswConfigPath )
141
- . toBe ( 'src/ ngsw-config.json' ) ;
141
+ . toBe ( 'ngsw-config.json' ) ;
142
142
} ) ;
143
143
144
144
} ) ;
You can’t perform that action at this time.
0 commit comments