gpc-remove-comments
v1.0.0
Published
This precompiler removes all or particular type of semantic comments from the feature file.
Downloads
3
Readme
gpc-remove-comments
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
inkeep
- To keep none of the comments, pass the
CommentType.NONE
inkeep
(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.