From 220a9d98480c507d602f61f0b008d73285a3c6da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=91=A8=F0=9F=8F=BC=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier-Muller?= Date: Mon, 30 Jul 2018 14:38:27 +0200 Subject: [PATCH 1/8] Add publish.sh to publish to NPM-JS and Github Pages. --- bundle-beta.sh | 4 ++- publish.sh | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 1 deletion(-) create mode 100755 publish.sh diff --git a/bundle-beta.sh b/bundle-beta.sh index 391a1d2f37703..204d765cfd6ec 100755 --- a/bundle-beta.sh +++ b/bundle-beta.sh @@ -26,7 +26,8 @@ echo "Staging: ${staging}" # │ └ maven # ├─ y # │ └─ npm -# └─ node_modules +# ├─ node_modules +# └─ .version # Creating a `y-npm` registry echo "Preparing local NPM registry" @@ -57,6 +58,7 @@ ln -s node_modules/aws-cdk-docs/dist/docs docs # Create an archive under ./dist echo "Creating ZIP bundle" version="$(cat ${root}/lerna.json | grep version | cut -d '"' -f4)" +echo ${version} > .version dist=${root}/dist output=${dist}/aws-cdk-${version}.zip rm -fr ${dist} diff --git a/publish.sh b/publish.sh new file mode 100755 index 0000000000000..fa9b20c12575e --- /dev/null +++ b/publish.sh @@ -0,0 +1,97 @@ +#!/bin/bash +set -euo pipefail + +### +# Usage: ./publish.sh +# +# Publishes the content of a release bundle ZIP file to the standard package +# repositories for the various supported languages: +# * Javascript & TypeScript: NPM +# * Documentation: GitHub Pages +# * (More to come later) +### + +if [ $# -ne 1 ]; then + echo "Missing release zip file argument" + echo "Usage: ./publish.sh " + exit 1 +fi + +RELEASE_BUNDLE=$1 +if [ ! -f ${RELEASE_BUNDLE} ]; then + echo "${RELEASE_BUNDLE} is not a file!" + exit 127 +fi + +############### +# PREPARATION # +############### + +declare -a CLEANUP=() +function cleanup() { + for ((i = 0; i < ${#CLEANUP[@]}; i++ )) + do + eval "${CLEANUP[$i]}" + done + echo '🍻 Done!' +} +trap cleanup 'EXIT' + + +WORK_DIR=$(mktemp -d) +CLEANUP+=("echo '🚮 Cleaning up working directory'" "rm -fr ${WORK_DIR}") +echo "💼 Working directory: ${WORK_DIR}" + +echo "🗜 Unzipping release bundle (be patient - this may take a while)" +unzip -q ${RELEASE_BUNDLE} -d ${WORK_DIR} + +####### +# NPM # +####### + +echo "📦 Publishing to NPM" +REGISTRY='https://registry.npmjs.org/' +OLD_REGISTRY=$(npm config get registry) +if [ ${OLD_REGISTRY} != ${REGISTRY} ]; then + echo "👉 Switching to NPM registry ${REGISTRY}" + npm config set registry ${REGISTRY} + CLEANUP+=("echo '👈 Resetting NPM registry to ${OLD_REGISTRY}'" "npm config set registry ${OLD_REGISTRY}") +fi + +TOKENS=$(npm token list 2>&1 || echo '') +if echo ${TOKENS} | grep 'EAUTHUNKNOWN' > /dev/null; then + echo "🔑 Can't list tokens - apparently missing authentication info" + npm login +fi + +for TGZ in $(find ${WORK_DIR}/y/npm -iname '*.tgz'); do + npm publish $TGZ --access=public +done + +################ +# GitHub Pages # +################ + +echo "📖 Publishing to GitHub Pages" + +GIT_REPO=$(mktemp -d) +CLEANUP+=("echo '🚮 Cleaning up GitHub Pages working copy'" "rm -fr ${GIT_REPO}") + +DOC_STAGING=$(mktemp -d) +CLEANUP+=("echo '🚮 Cleaning up Documentations staging directory'" "rm -fr ${DOC_STAGING}") + +( + cd ${DOC_STAGING} + ${WORK_DIR}/bin/y-npm i aws-cdk-docs --no-save +) + +git clone -b gh-pages --depth=1 ssh://github.com/awslabs/aws-cdk ${GIT_REPO} +rsync -ar --delete --exclude=/.git ${DOC_STAGING}/node_modules/aws-cdk-docs/dist/docs/ ${GIT_REPO}/ +( + cd ${GIT_REPO} + git add . + git commit -m "Release $(cat ${WORK_DIR}/.version)" + git push +) + +echo "✅ All OK!" From 7829bd905081a4768d9db3dba3eb3236826250a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=91=A8=F0=9F=8F=BC=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier-Muller?= Date: Mon, 30 Jul 2018 15:02:42 +0200 Subject: [PATCH 2/8] Publish documentations to historized folder, too. --- publish.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/publish.sh b/publish.sh index fa9b20c12575e..0086d78f987cd 100755 --- a/publish.sh +++ b/publish.sh @@ -45,6 +45,8 @@ echo "💼 Working directory: ${WORK_DIR}" echo "🗜 Unzipping release bundle (be patient - this may take a while)" unzip -q ${RELEASE_BUNDLE} -d ${WORK_DIR} +PKG_VERSION=$(cat ${WORK_DIR}/.version) + ####### # NPM # ####### @@ -86,11 +88,15 @@ CLEANUP+=("echo '🚮 Cleaning up Documentations staging directory'" "rm -fr ${D ) git clone -b gh-pages --depth=1 ssh://github.com/awslabs/aws-cdk ${GIT_REPO} -rsync -ar --delete --exclude=/.git ${DOC_STAGING}/node_modules/aws-cdk-docs/dist/docs/ ${GIT_REPO}/ +mkdir -p ${GIT_REPO}/versions + +rsync -ar --delete --exclude=/.git --exclude=/versions ${DOC_STAGING}/node_modules/aws-cdk-docs/dist/docs/ ${GIT_REPO}/ +rsync -ar --delete ${DOC_STAGING}/node_modules/aws-cdk-docs/dist/docs/ ${GIT_REPO}/versions/${PKG_VERSION}/ + ( cd ${GIT_REPO} git add . - git commit -m "Release $(cat ${WORK_DIR}/.version)" + git commit -m "Release ${PKG_VERSION}" git push ) From bfe05b05ca47d16a82a881752833923380aeb0f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=91=A8=F0=9F=8F=BC=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier-Muller?= Date: Mon, 30 Jul 2018 15:15:44 +0200 Subject: [PATCH 3/8] Make cdk docs open github pages --- README.md | 4 ++-- bundle-beta.sh | 6 +++--- packages/aws-cdk-docs/package.json | 1 + packages/aws-cdk/lib/commands/docs.ts | 15 +++------------ packages/aws-cdk/lib/commands/doctor.ts | 14 +------------- packages/aws-cdk/test/test.cdk-docs.ts | 11 ----------- packages/aws-cdk/test/test.cdk-doctor.ts | 12 ------------ publish.sh | 12 ++---------- 8 files changed, 12 insertions(+), 63 deletions(-) diff --git a/README.md b/README.md index f2036617a573d..647c3e7a9a5ec 100644 --- a/README.md +++ b/README.md @@ -70,10 +70,10 @@ Set-ExecutionPolicy Unrestricted ### Install the command-line toolkit and docs -Install (or update) `aws-cdk` and `aws-cdk-docs` globally +Install (or update) `aws-cdk` globally ```shell -y-npm install --global aws-cdk aws-cdk-docs # sudo might be needed +y-npm install --global aws-cdk # sudo might be needed ``` > `y-npm` is an npm wrapper which allows installing npm modules from a local repository located at `~/.cdk/y/npm`. `y-npm` will fall back to the public npm repository if a module cannot be found locally. diff --git a/bundle-beta.sh b/bundle-beta.sh index 204d765cfd6ec..99ca8c4ae9929 100755 --- a/bundle-beta.sh +++ b/bundle-beta.sh @@ -51,9 +51,9 @@ mkdir -p repo/maven rsync -av ${root}/packages/aws-cdk-java/maven-repo/ repo/maven/ rsync -av ${root}/node_modules/jsii-java-runtime/maven-repo/ repo/maven/ -# Symlink the docs website to docs -echo "Symlinking docs" -ln -s node_modules/aws-cdk-docs/dist/docs docs +# Copy the docs website to docs +echo "Copying docs" +cp -r ${root}/packages/aws-cdk-docs/dist/docs docs # Create an archive under ./dist echo "Creating ZIP bundle" diff --git a/packages/aws-cdk-docs/package.json b/packages/aws-cdk-docs/package.json index f13cd632f1de7..300a5b38d0ff2 100644 --- a/packages/aws-cdk-docs/package.json +++ b/packages/aws-cdk-docs/package.json @@ -1,6 +1,7 @@ { "name": "aws-cdk-docs", "version": "0.7.4-beta", + "private": true, "description": "AWS CDK Documentation", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/packages/aws-cdk/lib/commands/docs.ts b/packages/aws-cdk/lib/commands/docs.ts index aafef6025f581..9c9f307ab478f 100644 --- a/packages/aws-cdk/lib/commands/docs.ts +++ b/packages/aws-cdk/lib/commands/docs.ts @@ -2,7 +2,7 @@ import childProcess = require('child_process'); import colors = require('colors/safe'); import process = require('process'); import yargs = require('yargs'); -import { debug, error, warning } from '../../lib/logging'; +import { debug, warning } from '../../lib/logging'; export const command = 'docs'; export const describe = 'Opens the documentation in a browser'; @@ -21,17 +21,8 @@ export interface Arguments extends yargs.Arguments { } export async function handler(argv: Arguments): Promise { - let documentationIndexPath: string; - try { - // tslint:disable-next-line:no-var-require Taking an un-declared dep on aws-cdk-docs, to avoid a dependency circle - const docs = require('aws-cdk-docs'); - documentationIndexPath = docs.documentationIndexPath; - } catch (err) { - error('Unable to open CDK documentation - the aws-cdk-docs package appears to be missing. Please run `npm install -g aws-cdk-docs`'); - return -1; - } - - const browserCommand = argv.browser.replace(/%u/g, documentationIndexPath); + const docVersion = require('../../package.json').version; + const browserCommand = argv.browser.replace(/%u/g, `https://awslabs.github.io/aws-cdk/versions/${docVersion}/`); debug(`Opening documentation ${colors.green(browserCommand)}`); return await new Promise((resolve, reject) => { childProcess.exec(browserCommand, (err, stdout, stderr) => { diff --git a/packages/aws-cdk/lib/commands/doctor.ts b/packages/aws-cdk/lib/commands/doctor.ts index 6b9c68b4d2146..4ca07ebf8fb7e 100644 --- a/packages/aws-cdk/lib/commands/doctor.ts +++ b/packages/aws-cdk/lib/commands/doctor.ts @@ -19,8 +19,7 @@ export async function handler(): Promise { const verifications: Array<() => boolean | Promise> = [ displayVersionInformation, - displayAwsEnvironmentVariables, - checkDocumentationIsAvailable + displayAwsEnvironmentVariables ]; // ### Verifications ### @@ -42,14 +41,3 @@ function displayAwsEnvironmentVariables() { } return true; } - -function checkDocumentationIsAvailable() { - try { - const version = require('aws-cdk-docs/package.json').version; - print(`✅ AWS CDK Documentation: ${version}`); - return true; - } catch (e) { - print(`❌ AWS CDK Documentation: install using ${colors.green('y-npm install --global aws-cdk-docs')}`); - return false; - } -} diff --git a/packages/aws-cdk/test/test.cdk-docs.ts b/packages/aws-cdk/test/test.cdk-docs.ts index 08abbd7fb171e..511f0fe3f80fd 100644 --- a/packages/aws-cdk/test/test.cdk-docs.ts +++ b/packages/aws-cdk/test/test.cdk-docs.ts @@ -20,7 +20,6 @@ module.exports = testCase({ cb(); }, async 'exits with 0 when everything is OK'(test: Test) { - mockery.registerMock('aws-cdk-docs', { documentationIndexPath: 'index.html' }); try { const result = await require('../lib/commands/docs').handler(argv); test.equal(result, 0, 'exit status was 0'); @@ -29,16 +28,6 @@ module.exports = testCase({ } finally { test.done(); } - }, - async 'exits with non-0 when documentation is missing'(test: Test) { - try { - const result = await require('../lib/commands/docs').handler(argv); - test.notEqual(result, 0, 'exit status was non-0'); - } catch (e) { - test.doesNotThrow(() => { throw e; }); - } finally { - test.done(); - } } } }); diff --git a/packages/aws-cdk/test/test.cdk-doctor.ts b/packages/aws-cdk/test/test.cdk-doctor.ts index 5399243e35c70..062044186bc16 100644 --- a/packages/aws-cdk/test/test.cdk-doctor.ts +++ b/packages/aws-cdk/test/test.cdk-doctor.ts @@ -16,8 +16,6 @@ module.exports = testCase({ cb(); }, async 'exits with 0 when everything is OK'(test: Test) { - mockery.registerMock('aws-cdk-docs/package.json', { version: 'x.y.z' }); - try { const result = await require('../lib/commands/doctor').handler(); test.equal(result, 0, 'exit status was 0'); @@ -26,16 +24,6 @@ module.exports = testCase({ } finally { test.done(); } - }, - async 'exits with non-0 when documentation is missing'(test: Test) { - try { - const result = await require('../lib/commands/doctor').handler(); - test.notEqual(result, 0, 'exit status was non-0'); - } catch (e) { - test.doesNotThrow(() => e); - } finally { - test.done(); - } } } }); diff --git a/publish.sh b/publish.sh index 0086d78f987cd..f0ca30df446c8 100755 --- a/publish.sh +++ b/publish.sh @@ -79,19 +79,11 @@ echo "📖 Publishing to GitHub Pages" GIT_REPO=$(mktemp -d) CLEANUP+=("echo '🚮 Cleaning up GitHub Pages working copy'" "rm -fr ${GIT_REPO}") -DOC_STAGING=$(mktemp -d) -CLEANUP+=("echo '🚮 Cleaning up Documentations staging directory'" "rm -fr ${DOC_STAGING}") - -( - cd ${DOC_STAGING} - ${WORK_DIR}/bin/y-npm i aws-cdk-docs --no-save -) - git clone -b gh-pages --depth=1 ssh://github.com/awslabs/aws-cdk ${GIT_REPO} mkdir -p ${GIT_REPO}/versions -rsync -ar --delete --exclude=/.git --exclude=/versions ${DOC_STAGING}/node_modules/aws-cdk-docs/dist/docs/ ${GIT_REPO}/ -rsync -ar --delete ${DOC_STAGING}/node_modules/aws-cdk-docs/dist/docs/ ${GIT_REPO}/versions/${PKG_VERSION}/ +rsync -ar --delete --exclude=/.git --exclude=/versions ${WORK_DIR}/docs/ ${GIT_REPO}/ +rsync -ar --delete ${WORK_DIR}/docs/ ${GIT_REPO}/versions/${PKG_VERSION}/ ( cd ${GIT_REPO} From e9c296f76714112ec86435c0d37eef1ee302e893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=91=A8=F0=9F=8F=BC=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier-Muller?= Date: Mon, 30 Jul 2018 15:31:41 +0200 Subject: [PATCH 4/8] Make URL to documentation visible in case opening the browser fails. --- packages/aws-cdk/lib/commands/docs.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/aws-cdk/lib/commands/docs.ts b/packages/aws-cdk/lib/commands/docs.ts index 9c9f307ab478f..e70628fedfaed 100644 --- a/packages/aws-cdk/lib/commands/docs.ts +++ b/packages/aws-cdk/lib/commands/docs.ts @@ -2,7 +2,7 @@ import childProcess = require('child_process'); import colors = require('colors/safe'); import process = require('process'); import yargs = require('yargs'); -import { debug, warning } from '../../lib/logging'; +import { debug, print, warning } from '../../lib/logging'; export const command = 'docs'; export const describe = 'Opens the documentation in a browser'; @@ -20,13 +20,18 @@ export interface Arguments extends yargs.Arguments { browser: string } -export async function handler(argv: Arguments): Promise { +export function handler(argv: Arguments): Promise { const docVersion = require('../../package.json').version; - const browserCommand = argv.browser.replace(/%u/g, `https://awslabs.github.io/aws-cdk/versions/${docVersion}/`); + const url = `https://awslabs.github.io/aws-cdk/versions/${docVersion}/`; + const browserCommand = argv.browser.replace(/%u/g, url); debug(`Opening documentation ${colors.green(browserCommand)}`); - return await new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { childProcess.exec(browserCommand, (err, stdout, stderr) => { - if (err) { return reject(err); } + if (err) { + warning(`An error occurred when trying to open a browser: ${err.message}`); + print(`The documentation can be found at 🔗 ${colors.green(url)}`); + return resolve(127); + } if (stdout) { debug(stdout); } if (stderr) { warning(stderr); } resolve(0); From b252fb1903fdf13ad06d8b24d4a95715b9a87561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=91=A8=F0=9F=8F=BC=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier-Muller?= Date: Mon, 30 Jul 2018 15:38:24 +0200 Subject: [PATCH 5/8] Unconditionally showing URL in output of cdk docs --- packages/aws-cdk/lib/commands/docs.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/aws-cdk/lib/commands/docs.ts b/packages/aws-cdk/lib/commands/docs.ts index e70628fedfaed..9b557299b5365 100644 --- a/packages/aws-cdk/lib/commands/docs.ts +++ b/packages/aws-cdk/lib/commands/docs.ts @@ -23,13 +23,13 @@ export interface Arguments extends yargs.Arguments { export function handler(argv: Arguments): Promise { const docVersion = require('../../package.json').version; const url = `https://awslabs.github.io/aws-cdk/versions/${docVersion}/`; + print(`Docs for this version can be found at 🔗 ${colors.green(url)}`); const browserCommand = argv.browser.replace(/%u/g, url); debug(`Opening documentation ${colors.green(browserCommand)}`); return new Promise((resolve, _reject) => { childProcess.exec(browserCommand, (err, stdout, stderr) => { if (err) { - warning(`An error occurred when trying to open a browser: ${err.message}`); - print(`The documentation can be found at 🔗 ${colors.green(url)}`); + debug(`An error occurred when trying to open a browser: ${err.stack || err.message}`); return resolve(127); } if (stdout) { debug(stdout); } From 18c758ddc39c611d9263d1684a9bea81fd1f6ab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=91=A8=F0=9F=8F=BC=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier-Muller?= Date: Mon, 30 Jul 2018 15:45:25 +0200 Subject: [PATCH 6/8] Fix broken test. --- packages/aws-cdk/package.json | 2 +- packages/aws-cdk/test/test.cdk-docs.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/aws-cdk/package.json b/packages/aws-cdk/package.json index d75312d040b69..c77d731c1b31f 100644 --- a/packages/aws-cdk/package.json +++ b/packages/aws-cdk/package.json @@ -21,7 +21,7 @@ }, "nyc": { "lines": 8, - "branches": 3 + "branches": 2.9 }, "author": { "name": "Amazon Web Services", diff --git a/packages/aws-cdk/test/test.cdk-docs.ts b/packages/aws-cdk/test/test.cdk-docs.ts index 511f0fe3f80fd..a30c4c2d9bb44 100644 --- a/packages/aws-cdk/test/test.cdk-docs.ts +++ b/packages/aws-cdk/test/test.cdk-docs.ts @@ -9,6 +9,7 @@ module.exports = testCase({ mockery.registerMock('../../lib/logging', { debug() { return; }, error() { return; }, + print() { return; }, warning() { return; } }); mockery.enable({ useCleanCache: true, warnOnReplace: true, warnOnUnregistered: false }); From 8ae9eb01378aeb2b60028c997e4caa5206a1834b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=91=A8=F0=9F=8F=BC=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier-Muller?= Date: Mon, 30 Jul 2018 15:50:01 +0200 Subject: [PATCH 7/8] Ouput URL only --- packages/aws-cdk/lib/commands/docs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk/lib/commands/docs.ts b/packages/aws-cdk/lib/commands/docs.ts index 9b557299b5365..7c9a9524f4a9b 100644 --- a/packages/aws-cdk/lib/commands/docs.ts +++ b/packages/aws-cdk/lib/commands/docs.ts @@ -23,7 +23,7 @@ export interface Arguments extends yargs.Arguments { export function handler(argv: Arguments): Promise { const docVersion = require('../../package.json').version; const url = `https://awslabs.github.io/aws-cdk/versions/${docVersion}/`; - print(`Docs for this version can be found at 🔗 ${colors.green(url)}`); + print(colors.green(url)); const browserCommand = argv.browser.replace(/%u/g, url); debug(`Opening documentation ${colors.green(browserCommand)}`); return new Promise((resolve, _reject) => { From a62fb8549aac1508d8de469ed6676861143821d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=91=A8=F0=9F=8F=BC=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier-Muller?= Date: Mon, 30 Jul 2018 15:53:55 +0200 Subject: [PATCH 8/8] Exit success even if opening the browser fails. --- packages/aws-cdk/lib/commands/docs.ts | 2 +- packages/aws-cdk/package.json | 2 +- packages/aws-cdk/test/test.cdk-docs.ts | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/aws-cdk/lib/commands/docs.ts b/packages/aws-cdk/lib/commands/docs.ts index 7c9a9524f4a9b..e6fdb8f282ee9 100644 --- a/packages/aws-cdk/lib/commands/docs.ts +++ b/packages/aws-cdk/lib/commands/docs.ts @@ -30,7 +30,7 @@ export function handler(argv: Arguments): Promise { childProcess.exec(browserCommand, (err, stdout, stderr) => { if (err) { debug(`An error occurred when trying to open a browser: ${err.stack || err.message}`); - return resolve(127); + return resolve(0); } if (stdout) { debug(stdout); } if (stderr) { warning(stderr); } diff --git a/packages/aws-cdk/package.json b/packages/aws-cdk/package.json index c77d731c1b31f..d75312d040b69 100644 --- a/packages/aws-cdk/package.json +++ b/packages/aws-cdk/package.json @@ -21,7 +21,7 @@ }, "nyc": { "lines": 8, - "branches": 2.9 + "branches": 3 }, "author": { "name": "Amazon Web Services", diff --git a/packages/aws-cdk/test/test.cdk-docs.ts b/packages/aws-cdk/test/test.cdk-docs.ts index a30c4c2d9bb44..193795c601b09 100644 --- a/packages/aws-cdk/test/test.cdk-docs.ts +++ b/packages/aws-cdk/test/test.cdk-docs.ts @@ -29,6 +29,21 @@ module.exports = testCase({ } finally { test.done(); } + }, + async 'exits with 0 when opening the browser fails'(test: Test) { + mockery.registerMock('child_process', { + exec(_: string, cb: (err: Error, stdout?: string, stderr?: string) => void) { + cb(new Error('TEST')); + } + }); + try { + const result = await require('../lib/commands/docs').handler(argv); + test.equal(result, 0, 'exit status was 0'); + } catch (e) { + test.doesNotThrow(() => { throw e; }); + } finally { + test.done(); + } } } });