Skip to content

Commit

Permalink
Merge pull request #9 from Green-Software-Foundation/init-if-core
Browse files Browse the repository at this point in the history
Init if core dependency
  • Loading branch information
jmcook1186 authored Jun 12, 2024
2 parents 11690f2 + 843b070 commit d139a1c
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
. "$(dirname -- "$0")/_/husky.sh"

npm run lint
npm test
# npm test
npm run fix:package
27 changes: 20 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"url": "https://github.com/Green-Software-Foundation/if-plugin-template/issues/new?assignees=&labels=feedback&projects=&template=feedback.md&title=Feedback+-+"
},
"dependencies": {
"@grnsft/if-core": "^0.0.3",
"typescript": "^5.1.6"
},
"devDependencies": {
Expand Down
21 changes: 19 additions & 2 deletions src/lib/my-custom-plugin/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,34 @@
import {ERRORS} from '@grnsft/if-core';
import {PluginParams, ExecutePlugin} from '@grnsft/if-core/types';

import {YourGlobalConfig} from './types';
import {PluginInterface, PluginParams} from '../types/interface';

const {GlobalConfigError} = ERRORS;

export const MyCustomPlugin = (
globalConfig: YourGlobalConfig
): PluginInterface => {
): ExecutePlugin => {
const metadata = {
kind: 'execute',
};

/**
* Validates global config.
*/
const validateGlobalConfig = () => {
if (!globalConfig) {
throw new GlobalConfigError('My custom message here.');
}

// validator checks can be applied if needed
};

/**
* Execute's strategy description here.
*/
const execute = async (inputs: PluginParams[]): Promise<PluginParams[]> => {
validateGlobalConfig();

return inputs.map(input => {
// your logic here
globalConfig;
Expand Down
12 changes: 0 additions & 12 deletions src/lib/types/interface.ts

This file was deleted.

0 comments on commit d139a1c

Please sign in to comment.