Skip to content

Commit

Permalink
fix: export firebaseJsonDir from config parser func (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
jthegedus authored May 10, 2021
1 parent dca704b commit 5ec2e18
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function isString(parameter) {
* @returns {{
* functions: false | { name: string, source: string };
* cloudRun: false | { serviceId: string, region: string };
* firebaseJsonDir: string;
* publicDir: string
* }}
*/
Expand Down Expand Up @@ -106,7 +107,8 @@ function parseFirebaseConfiguration({hostingSite, sourceRewriteMatch, firebaseJs
serviceId: rewriteConfig.run.serviceId,
region: rewriteConfig.run?.region || 'us-central1'
} : false,
publicDir: path.join(path.dirname(firebaseJson), hostingConfig.public)
publicDir: path.join(path.dirname(firebaseJson), hostingConfig.public),
firebaseJsonDir: firebaseJson

This comment has been minimized.

Copy link
@nhe23

nhe23 May 10, 2021

Shouldn't this be firebaseJsonDir:path.dirname(firebaseJson)? Because the way it is now the path including the filename is returned which leads to this error: image

This comment has been minimized.

Copy link
@jthegedus

jthegedus May 10, 2021

Author Owner

Indeed, my mistake

};
}

Expand Down
8 changes: 4 additions & 4 deletions tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test(
t => {
const config = {hostingSite: undefined, sourceRewriteMatch: '**', firebaseJson: fileURLToPath(new URL('./fixtures/successes/cf_site.json', import.meta.url))};
const result = parseFirebaseConfiguration(config);
const expectedResult = {functions: {name: 'some_func', source: path.join(path.dirname(config.firebaseJson), 'functions')}, cloudRun: false, publicDir: path.join(path.dirname(config.firebaseJson), 'app')};
const expectedResult = {functions: {name: 'some_func', source: path.join(path.dirname(config.firebaseJson), 'functions')}, cloudRun: false, publicDir: path.join(path.dirname(config.firebaseJson), 'app'), firebaseJsonDir: config.firebaseJson};

t.deepEqual(result, expectedResult);
}
Expand All @@ -20,7 +20,7 @@ test(
t => {
const config = {hostingSite: 'app', sourceRewriteMatch: '**', firebaseJson: fileURLToPath(new URL('./fixtures/successes/cf_sites.json', import.meta.url))};
const result = parseFirebaseConfiguration(config);
const expectedResult = {functions: {name: 'some_func', source: path.join(path.dirname(config.firebaseJson), 'functions')}, cloudRun: false, publicDir: path.join(path.dirname(config.firebaseJson), 'app')};
const expectedResult = {functions: {name: 'some_func', source: path.join(path.dirname(config.firebaseJson), 'functions')}, cloudRun: false, publicDir: path.join(path.dirname(config.firebaseJson), 'app'), firebaseJsonDir: config.firebaseJson};

t.deepEqual(result, expectedResult);
}
Expand All @@ -31,7 +31,7 @@ test(
t => {
const config = {hostingSite: undefined, sourceRewriteMatch: '**', firebaseJson: fileURLToPath(new URL('./fixtures/successes/cr_site.json', import.meta.url))};
const result = parseFirebaseConfiguration(config);
const expectedResult = {functions: false, cloudRun: {serviceId: 'some-service', region: 'us-central1'}, publicDir: path.join(path.dirname(config.firebaseJson), 'app')};
const expectedResult = {functions: false, cloudRun: {serviceId: 'some-service', region: 'us-central1'}, publicDir: path.join(path.dirname(config.firebaseJson), 'app'), firebaseJsonDir: config.firebaseJson};

t.deepEqual(result, expectedResult);
}
Expand All @@ -42,7 +42,7 @@ test(
t => {
const config = {hostingSite: 'app', sourceRewriteMatch: '**', firebaseJson: fileURLToPath(new URL('./fixtures/successes/cr_sites.json', import.meta.url))};
const result = parseFirebaseConfiguration(config);
const expectedResult = {functions: false, cloudRun: {serviceId: 'some-service', region: 'us-central1'}, publicDir: path.join(path.dirname(config.firebaseJson), 'app')};
const expectedResult = {functions: false, cloudRun: {serviceId: 'some-service', region: 'us-central1'}, publicDir: path.join(path.dirname(config.firebaseJson), 'app'), firebaseJsonDir: config.firebaseJson};

t.deepEqual(result, expectedResult);
}
Expand Down

0 comments on commit 5ec2e18

Please sign in to comment.