You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const{ parseHtml }=require('contentful-html-rich-text-converter');consthtml=process.env.HTML_INPUT;// The HTML_INPUT environment variable is used to provide the required inputconstresult=parseHtml(html);console.log(JSON.stringify(result));// The result of the execution is serialized and printed into the console
Note: Before publishing the project, remove all auto-generated files like project.json and tsconfig.json, as they could interfere in an unwanted way.
Project Name: my-application
command.js
import{Command}from"sdk/platform";import{Response}from"sdk/http";constcommandResult=Command.execute('node index.js',{// The command to be executedworkingDirectory: '/target/dirigible/repository/root/registry/public/external-dependency'// Specify the location of the external-dependency project in the Dirigible Registry},{HTML_INPUT: '<ul><li><p>a</p></li><li><p>b</p></li><li><p>c</p></li></ul><p></p>'// Provide the required environment variables});constresult=JSON.parse(commandResult.standardOutput);// Parse the result that was printed in the consoleResponse.println(JSON.stringify(result,null,4));
Note: In this example it's assumed that the dirigiblelabs/dirigible Docker container is used, if the Dirigible application is started in another way, then the path to the Registry could be different (/target/dirigible/repository/root/registry/public/<projectName>).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
We have the following scenario - NPM dependency is needed for certain functionality (e.g. contentful-html-rich-text-converter).
package.jsonfile and specify the dependency in thedependenciessection.npm installin the project.Terminalview orindex.jsfile, which would serve as interface between the Dirigible application and the NPM dependency.node index.js).Example
Project Name:
external-dependencypackage.json:
{ "dependencies": { "contentful-html-rich-text-converter": "1.0.11" } }index.js:
Project Name:
my-applicationcommand.js
Beta Was this translation helpful? Give feedback.
All reactions