UNPKG

@ibm-adw/skill-toolkit

Version:

Developing your own skills with IBM Automation Digital Worker Skill Toolkit

36 lines (33 loc) 1.17 kB
/* Licensed Materials - Property of IBM 5737-I23 Copyright IBM Corp. 2019. All Rights Reserved. U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ 'use strict'; const markdownIntoHtml = require('markdown-into-html'); const path = require('path'); module.exports = async function (req, res) { const SKILL_DIR_1 = process.argv[2]; const SKILL_DIR = path.resolve(process.env.PWD, SKILL_DIR_1); try { const documentationPath = require.resolve(`${SKILL_DIR}/skill-documentation.md`); const html_code = await markdownIntoHtml({ path: documentationPath, options: { linkify: false } }); res.status(200).send(html_code); } catch (error) { console.log(error); if (error.code === 'MODULE_NOT_FOUND') { res.status(200).send('<h1>No available documentation for this skill</h1>'); } else { res.status(200).send('<h1>There is a problem with the skill documentation.</h1> <p>Please check the server error message</p>'); } } };