Nutritious Pumpkin Meal

    gpc-replacer
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.1 • Public • Published

    gpc-replacer

    Downloads Version@npm Version@git CI Docs

    This GherKing Precompiler is responsible to replace keys in feature files with given values.

    Usage

    'use strict';
    const compiler = require('gherking');
    const { default: Replacer } = require('gpc-replacer');
    
    let ast = await compiler.load('./features/src/login.feature');
    ast = compiler.process(
        ast,
        new Replacer({
            // config
            stringToBeReplaced1: "stringToReplaceWith1",
            stringToBeReplaced2: "stringToReplaceWith2",
        })
    );
    await compiler.save('./features/dist/login.feature', ast, {
        lineBreak: '\r\n'
    });
    'use strict';
    import {load, process, save} from "gherking";
    import Replacer, { ReplacerConfig } from "gpc-replacer";
    
    let ast = await load("./features/src/login.feature");
    ast = process(
        ast,
        new Replacer({
            // config
            stringToBeReplaced1: "stringToReplaceWith1",
            stringToBeReplaced2: "stringToReplaceWith2",
        })
    );
    await save('./features/dist/login.feature', ast, {
        lineBreak: '\r\n'
    });

    This Replacer is responsible for exchanging predefined strings in the feature files. It inserts the provided text in the place held for them.

    As an input it needs the feature file to be modified, and a config json file, which contains the words to be replaced, and the words to replace them with. It is a regular json, where the keys are the words need replacing, and their values are the words they will get replaced by. In case the config file is not available, or its format is incorrect the Replacer throws an error.

    It replaces strings given in a format ${to_replace} in the input feature.

    It can find and replace such strings in the textual parts of a feature file:

    • Document: comments
    • Feature: name, description, comments
    • Rule: name, description, comments
    • Background: name, description, comments
    • Scenario Outline: name, decription, comments
    • Scenario: name, description, comments
    • Step: text, comment
    • Tag: name, value, comments
    • Examples: name, comments
    • Doc String: content, comment
    • Data Table, Table Rows: cell values, comments

    See examples for the input files and an output in the test/data folder.

    Other

    This package uses debug for logging, use gpc:replacer :

    DEBUG=gpc:replacer* gherking ...

    For detailed documentation see the TypeDocs documentation.

    Install

    npm i gpc-replacer

    DownloadsWeekly Downloads

    1,276

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    7.09 kB

    Total Files

    5

    Last publish

    Collaborators

    • monikalaszlo
    • rakur
    • wgula
    • szikszail
    • judit-nahaj
    • sorosz89