Skip to content

Commit 613f33a

Browse files
committed
Assert environment variables are provided at script start
1 parent 3041b35 commit 613f33a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

server/scripts/examples-ml5.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import fs from 'fs';
22
import rp from 'request-promise';
33
import Q from 'q';
4+
import { ok } from 'assert';
45

56
// TODO: Change branchName if necessary
67
const branchName = 'release';
@@ -10,10 +11,17 @@ const clientId = process.env.GITHUB_ID;
1011
const clientSecret = process.env.GITHUB_SECRET;
1112
const editorUsername = process.env.ML5_EXAMPLES_USERNAME;
1213
const personalAccessToken = process.env.EDITOR_API_ACCESS_TOKEN;
14+
const editorApiUrl = process.env.EDITOR_API_URL;
1315
const headers = {
1416
'User-Agent': 'p5js-web-editor/0.0.1'
1517
};
1618

19+
ok(clientId, 'GITHUB_ID is required');
20+
ok(clientSecret, 'GITHUB_SECRET is required');
21+
ok(editorUsername, 'ML5_EXAMPLES_USERNAME is required');
22+
ok(personalAccessToken, 'EDITOR_API_ACCESS_TOKEN is required');
23+
ok(editorApiUrl, 'EDITOR_API_URL is required');
24+
1725
//
1826
const githubRequestOptions = {
1927
url: baseUrl,
@@ -27,7 +35,7 @@ const githubRequestOptions = {
2735
};
2836

2937
const editorRequestOptions = {
30-
url: `${process.env.P5_API || 'http://localhost:8000/api'}/${editorUsername}`,
38+
url: `${editorApiUrl}/${editorUsername}`,
3139
method: 'GET',
3240
headers: {
3341
...headers,

0 commit comments

Comments
 (0)