-
Notifications
You must be signed in to change notification settings - Fork 385
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
102 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
// get extensionName from args | ||
// e.g node scripts/changeFirebaseJson.cjs firestore-send-email | ||
const extensionName = process.argv[2]; | ||
|
||
|
||
const filePath = path.join(__dirname,'_emulator','firebase.json'); // Adjust the path as necessary | ||
|
||
fs.readFile(filePath, { encoding: 'utf8' }, (err, data) => { | ||
if (err) { | ||
console.error('Error reading file:', err); | ||
return; | ||
} | ||
|
||
// Parse the JSON data | ||
let config = JSON.parse(data); | ||
|
||
const extensionsFields = { | ||
"firestore-send-email": { | ||
"firestore-send-email": "../firestore-send-email", | ||
"firestore-send-email-sendgrid": "../firestore-send-email" | ||
}, | ||
"delete-user-data": { | ||
"delete-user-data": "../delete-user-data" | ||
}, | ||
} | ||
|
||
|
||
|
||
// Update the extensions field | ||
config.extensions = { | ||
[extensionName]: extensionsFields[extensionName] | ||
}; | ||
|
||
// Convert the modified config back to a JSON string | ||
const updatedJson = JSON.stringify(config, null, 2); // Including null and 2 for pretty-printing | ||
|
||
// Write the JSON string back to the file | ||
fs.writeFile(filePath, updatedJson, (err) => { | ||
if (err) { | ||
console.error('Error writing file:', err); | ||
} else { | ||
console.log('firebase.json has been updated successfully!'); | ||
} | ||
}); | ||
}); |