1.0.0 • Published 5 years ago

merge-batch2json v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

Merge BATCH 2 JSON

Replace string in JSON using BATCH patter with BATCH file vars

Install using:

npm install merge-batch2json --save

Simple usage :

const merge = require('merge-batch2json');
var configData = await merge( __dirname + '\\myConfig.json', __dirname + '\\myVars.bat'  );

The myConfig.json has the following content:

{
    "connections":{
        "webservice":{
            "ip"    :"%SERVER_IP%",
            "port"  :"%SERVER_PORT%"
        }
    }
}

myVars.bat has the following content:

@ECHO OFF
cd %~dp0
SET SERVER_IP= 127.0.0.1
SET SERVER_PORT= 1234

The result output will be:

{
    "connections":{
        "webservice":{
            "ip"    :"127.0.0.1",
            "port"  :"1234"
        }
    }
}