Skip to content

Commit

Permalink
chore(release): fix duplicate keys in firebase.json (angular#10470)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasBurleson authored and mmalerba committed Mar 13, 2017
1 parent 6c209b9 commit 0f3ef64
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions release.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@
replaceBaseHref('latest');

//-- update firebase.json file
writeFirebaseJson();
updateFirebaseJson();
exec([ 'git commit --amend --no-edit -a' ], options);
done();

Expand All @@ -292,18 +292,20 @@
'cd ..'
);

function writeFirebaseJson () {
function updateFirebaseJson () {
fs.writeFileSync(options.cwd + '/firebase.json', getFirebaseJson());
function getFirebaseJson () {
var json = require(options.cwd + '/firebase.json');
json.rewrites = json.rewrites || [];
switch (json.rewrites.length) {
var json = require(options.cwd + '/firebase.json');
json.hosting.rewrites = json.hosting.rewrites || [];
var rewrites = json.hosting.rewrites;

switch (rewrites.length) {
case 0:
json.rewrites.push(getRewrite('HEAD'));
rewrites.push(getRewrite('HEAD'));
case 1:
json.rewrites.push(getRewrite('latest'));
rewrites.push(getRewrite('latest'));
default:
json.rewrites.push(getRewrite(newVersion));
rewrites.push(getRewrite(newVersion));
}
return JSON.stringify(json, null, 2);
function getRewrite (str) {
Expand Down

0 comments on commit 0f3ef64

Please sign in to comment.