8000 chore(ci): several fixes/improvements to Firebase deployments by gkalpak · Pull Request #17114 · angular/angular.js · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

chore(ci): several fixes/improvements to Firebase deployments #17114

Closed
wants to merge 9 commits into from
Closed
Prev Previous commit
fix(code.angularjs.org): correctly re-construct paths on Windows in `…
…sendStoredFile()`

Previously, the `sendStoredFile()` Firebase function used `.split('/')`
to split the request path into segments and later used `path.join()` to
join them back together. This worked fine on *nix based systems, which
use `/` as the path separator. On Windows, however, where `\` is the
path separator, the re-constructed paths could not be retrieved from the
Google Cloud Storage bucket. This prevented the Firebase emulators from
working correctly when testing the function locally on Windows.

This commit fixes the issue by using `.join('/')` to join the path
segments back together.
  • Loading branch information
gkalpak committed Feb 6, 2021
commit c653ab11ef1e77afe3770decb32a321ffaf4a465
5 changes: 2 additions & 3 deletions scripts/code.angularjs.org-firebase/functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const functions = require('firebase-functions');
const {Storage} = require('@google-cloud/storage');
const path = require('path');

const storage = new Storage();
const gcsBucketId = `${process.env.GCLOUD_PROJECT}.appspot.com`;
Expand Down Expand Up @@ -41,13 +40,13 @@ function sendStoredFile(request, response) {
return getDirectoryListing('/').catch(sendErrorResponse);
}

downloadSource = path.join.apply(null, filePathSegments);
downloadSource = filePathSegments.join('/');

downloadAndSend(downloadSource).catch(error => {
if (isDocsPath && error.code === 404) {
fileName = 'index.html';
filePathSegments = [version, 'docs', fileName];
downloadSource = path.join.apply(null, filePathSegments);
downloadSource = filePathSegments.join('/');

return downloadAndSend(downloadSource);
}
Expand Down
0