Options
All
  • Public
  • Public/Protected
  • All
Menu

gpc-remove-comments

gpc-remove-comments

Downloads Version@npm Version@git CI Docs

This precompiler removes all or particular type of semantic comments from the feature file.

Usage

'use strict';
const compiler = require('gherking');
const { default: RemoveComments, CommentType } = require('gpc-remove-comments');

let ast = await compiler.load('./features/src/login.feature');
ast = compiler.process(
ast,
new RemoveComments({
keep: CommentType.STEP | CommentType.PRECEDING
})
);
await compiler.save('./features/dist/login.feature', ast, {
lineBreak: '\r\n'
});
'use strict';
import {load, process, save} from "gherking";
import RemoveComments, { CommentType } from "gpc-remove-comments";

let ast = await load("./features/src/login.feature");
ast = process(
ast,
new RemoveComments({
keep: CommentType.STEP | CommentType.PRECEDING
})
);
await save('./features/dist/login.feature', ast, {
lineBreak: '\r\n'
});

Configuration

By default, the precompiler removes all comments. But to keep certain type of comments, the keep configuration options and the CommentType flags can be used.

  • To keep all comments, pass the CommentType.ALL in keep
  • To keep none of the comments, pass the CommentType.NONE in keep (this is the default)
  • To keep any or more types, pass the value using the binary OR: CommentType.STEP | CommentType.TAG

.gherking.json

When the configuration is set in the .gherking.json, the names of the CommentType can be used and passed as a string array, e.g.

{
"compilers": [
{
"path": "gpc-remove-comments",
"configuration": {
"keep": ["STEP", "TAG"]
}
}
]
}

Other

This package uses debug for logging, use gpc:remove-comments :

DEBUG=gpc:remove-comments* gherking ...

For detailed documentation see the TypeDocs documentation.

Generated using TypeDoc