Skip to content

Commit

Permalink
fix: let's detect the right dist dir instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Skn0tt committed Nov 8, 2023
1 parent 8297435 commit a322cfe
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
16 changes: 14 additions & 2 deletions packages/build-info/src/frameworks/angular.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,25 @@ beforeEach((ctx) => {
test('should detect Angular', async ({ fs }) => {
const cwd = mockFileSystem({
'package.json': JSON.stringify({ dependencies: { '@angular/cli': '17.0.0' } }),
'angular.json': '',
'angular.json': JSON.stringify({
projects: {
demo: {
architect: {
build: {
options: {
outputPath: 'dist/demo',
},
},
},
},
},
}),
})
const detected = await new Project(fs, cwd).detectFrameworks()
expect(detected?.[0].id).toBe('angular')
expect(detected?.[0].name).toBe('Angular')
expect(detected?.[0].build.command).toBe('ng build --prod')
expect(detected?.[0].build.directory).toBe('')
expect(detected?.[0].build.directory).toBe('dist/demo/browser')
expect(detected?.[0].dev?.command).toBe('ng serve')
expect(detected?.[0].plugins).toEqual(['@netlify/angular-runtime'])
})
Expand Down
10 changes: 9 additions & 1 deletion packages/build-info/src/frameworks/angular.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@ export class Angular extends BaseFramework implements Framework {
if (this.detected) {
if (this.version && gte(this.version, '17.0.0-rc')) {
this.plugins.push('@netlify/angular-runtime')
this.build.directory = '' // will be overwritten by the plugin
const angularJson = await this.project.fs.gracefullyReadFile('angular.json')
if (angularJson) {
const { projects, defaultProject } = JSON.parse(angularJson)
const project = projects[defaultProject ?? Object.keys(projects)[0]]
const outputPath = project?.architect?.build?.options?.outputPath
if (outputPath) {
this.build.directory = `${outputPath}/browser`
}
}
}
return this as DetectedFramework
}
Expand Down

0 comments on commit a322cfe

Please sign in to comment.