Downloads Version@npm Version@git CI Docs
This precompiler removes all or particular type of semantic comments from the feature file.
'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' });
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.ALLinkeep - To keep none of the comments, pass the
CommentType.NONEinkeep(this is the default) - To keep any or more types, pass the value using the binary OR:
CommentType.STEP | CommentType.TAG
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"]
}
}
]
}This package uses debug for logging, use gpc:remove-comments :
DEBUG=gpc:remove-comments* gherking ...For detailed documentation see the TypeDocs documentation.