From 59c962d8fc71fe38dd0f2b5a48a1468291cb2be6 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Wed, 7 Jul 2021 12:36:48 +0200 Subject: [PATCH] Added sample for custom actions --- README.md | 14 ++++++++++---- sample/script-sample.js | 10 ++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 sample/script-sample.js diff --git a/README.md b/README.md index 3b1a85bd..70997666 100644 --- a/README.md +++ b/README.md @@ -32,12 +32,18 @@ The current workspace-, file-path, and front matter data will be passed as an ar ```javascript const arguments = process.argv; -const workspaceArg = arguments[2]; -const fileArg = arguments[3]; -const dataArg = arguments[4]; -const data = dataArg && typeof dataArg === "string" ? JSON.parse(dataArg) : null; + +if (arguments && arguments.length > 0) { + const workspaceArg = arguments[2]; // The workspace path + const fileArg = arguments[3]; // The file path + const frontMatterArg = arguments[4]; // Front matter data + + console.log(`The content returned for your notification.`); +} ``` +> A sample file can be found here: ![script-sample.js](./sample/script-sample.js) + The output of the script will be passed as a notification, and it allows you to copy the output. ![](./assets/custom-action-notification.png) diff --git a/sample/script-sample.js b/sample/script-sample.js new file mode 100644 index 00000000..e950e688 --- /dev/null +++ b/sample/script-sample.js @@ -0,0 +1,10 @@ + +const arguments = process.argv; + +if (arguments && arguments.length > 0) { + const workspaceArg = arguments[2]; // The workspace path + const fileArg = arguments[3]; // The file path + const frontMatterArg = arguments[4]; // Front matter data + + console.log(`The content returned for your notification.`); +} \ No newline at end of file