Skip to content

Commit

Permalink
Fix write certificate on first run command (#159)
Browse files Browse the repository at this point in the history
* fix write certificate on first run command

* update generator-aio-app
  • Loading branch information
moritzraho authored Feb 14, 2020
1 parent d2ab6eb commit 13d1308
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dependencies": {
"@adobe/aio-app-scripts": "^0.11.0",
"@adobe/aio-lib-core-config": ">=1.2.8",
"@adobe/generator-aio-app": "^0.5.1",
"@adobe/generator-aio-app": "^0.5.4",
"@oclif/command": "^1.5.11",
"@oclif/config": "^1.12.9",
"chalk": "^3.0.0",
Expand Down
10 changes: 5 additions & 5 deletions src/commands/app/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ class Run extends BaseCommand {

/* check if there are certificates available, and generate them if not ... */
try {
fs.ensureDirSync(path.dirname(PRIVATE_KEY_PATH))
await fs.ensureDir(path.dirname(PRIVATE_KEY_PATH))
// if they do not exists, attempt to create them
if (!fs.existsSync(PRIVATE_KEY_PATH) && !fs.existsSync(PUB_CERT_PATH)) {
if (!await fs.exists(PRIVATE_KEY_PATH) && !await fs.exists(PUB_CERT_PATH)) {
// 1. do they exist in global config?
const devConfig = coreConfig.get('aio-dev.dev-keys')
if (devConfig) {
// yes? write them to file
fs.writeFile(PRIVATE_KEY_PATH, devConfig.privateKey)
fs.writeFile(PUB_CERT_PATH, devConfig.publicCert)
await fs.writeFile(PRIVATE_KEY_PATH, devConfig.privateKey)
await fs.writeFile(PUB_CERT_PATH, devConfig.publicCert)
} else {
// 2. generate them
const CertCmd = this.config.findCommand('certificate:generate')
Expand Down Expand Up @@ -97,7 +97,7 @@ class Run extends BaseCommand {
}
}
// if they now exist ... use them in the options
if (fs.existsSync(PRIVATE_KEY_PATH) && fs.existsSync(PUB_CERT_PATH)) {
if (await fs.exists(PRIVATE_KEY_PATH) && await fs.exists(PUB_CERT_PATH)) {
runOptions.https = {
cert: PUB_CERT_PATH, // Path to custom certificate
key: PRIVATE_KEY_PATH // Path to custom key
Expand Down

1 comment on commit 13d1308

@purplecabbage
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why change all the calls to awaits? why not just use writeFIleSync like I should have in the first place?
or better yet, use outputFIleSync and we can get rid of the fs.ensureDir(path.dirname( ...

Please sign in to comment.