@@ -45,9 +45,9 @@ async function generateSSO({ config /* &mut */, functionsDir, publishDir }) {
45
45
path . join ( functionsDir , `${ authFunc } .js` ) ,
46
46
)
47
47
48
- config . redirects = config . redirects || [ ]
48
+ const redirects = config . redirects || [ ]
49
49
/** @type {NetlifyRedirect[] } */
50
- const gatedRedirects = config . redirects . map ( ( redirect ) => ( {
50
+ const gatedRedirects = redirects . map ( ( redirect ) => ( {
51
51
...redirect ,
52
52
conditions : {
53
53
Role : [ 'netlify' ] ,
@@ -83,7 +83,7 @@ async function generateSSO({ config /* &mut */, functionsDir, publishDir }) {
83
83
} ,
84
84
]
85
85
86
- config . redirects = [ ...gatedRedirects , ...additionalRedirects ]
86
+ return { ... config , redirects : [ ...gatedRedirects , ...additionalRedirects ] }
87
87
}
88
88
89
89
const DEFAULT_FUNCTIONS_SRC = 'netlify-automatic-functions'
@@ -100,14 +100,14 @@ module.exports = {
100
100
// Build constants
101
101
constants : { PUBLISH_DIR , FUNCTIONS_SRC = DEFAULT_FUNCTIONS_SRC } ,
102
102
} ) {
103
- await generateSSO ( {
103
+ const newConfig = await generateSSO ( {
104
104
config : netlifyConfig ,
105
105
functionsDir : FUNCTIONS_SRC ,
106
106
publishDir : PUBLISH_DIR ,
107
107
} )
108
108
109
109
console . log ( 'Writing updated config to publish dir...' )
110
- const config_out = toml . stringify ( netlifyConfig )
110
+ const config_out = toml . stringify ( newConfig )
111
111
await fs . writeFile ( path . join ( PUBLISH_DIR , 'netlify.toml' ) , config_out )
112
112
} ,
113
113
}
0 commit comments