From 13d130805579177c99f32262fe99ea42bd3d044f Mon Sep 17 00:00:00 2001 From: moritzraho Date: Fri, 14 Feb 2020 12:24:27 +0100 Subject: [PATCH] Fix write certificate on first run command (#159) * fix write certificate on first run command * update generator-aio-app --- package.json | 2 +- src/commands/app/run.js | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 594f9328..e6aa52e9 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/commands/app/run.js b/src/commands/app/run.js index 0281389f..281b7218 100644 --- a/src/commands/app/run.js +++ b/src/commands/app/run.js @@ -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') @@ -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