Skip to content

Commit bb792ab

Browse files
committed
fix: fix issue with missing config file
1 parent 8c2d132 commit bb792ab

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

src/commands/upload.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ function findConfig(path: string): Config {
4545
} else {
4646
return {};
4747
}
48-
// TODO: Validate config schema.
49-
return yaml.safeLoad(fs.readFileSync(configPath, 'utf8')) as Config;
48+
return (yaml.safeLoad(fs.readFileSync(configPath, 'utf8')) as Config) || {};
5049
}
5150

5251
export class UploadCommand {
@@ -60,23 +59,14 @@ export class UploadCommand {
6059
const ttl = this.options.ttl ? new Date(this.options.ttl) : undefined;
6160
const site = this.options.site || config.site;
6261

63-
let bucket = this.options.bucket;
64-
if (!bucket && config.google_cloud_project) {
65-
bucket = `${config.google_cloud_project}.appspot.com`;
66-
} else if (!bucket && process.env.GOOGLE_CLOUD_PROJECT) {
67-
bucket = `${process.env.GOOGLE_CLOUD_PROJECT}.appspot.com`;
68-
}
69-
if (!bucket) {
70-
throw new Error(
71-
'Unable to determine which Google Cloud Storage bucket to use. You must specify a `google_cloud_project` in `fileset.yaml` or specify a `GOOGLE_CLOUD_PROJECT` environment variable.'
72-
);
73-
}
74-
7562
const googleCloudProject =
7663
config.google_cloud_project || process.env.GOOGLE_CLOUD_PROJECT;
7764
if (!googleCloudProject) {
78-
throw new Error('Unable to determine the Google Cloud project.');
65+
throw new Error(
66+
'Unable to determine which Google Cloud Storage bucket to use. You must specify a `google_cloud_project` in `fileset.yaml` or specify a `GOOGLE_CLOUD_PROJECT` environment variable.'
67+
);
7968
}
69+
const bucket = this.options.bucket || `${googleCloudProject}.appspot.com`;
8070

8171
const manifestObj = new manifest.Manifest(
8272
(site as string) || 'default',

0 commit comments

Comments
 (0)