Skip to content

Instantly share code, notes, and snippets.

@a0viedo
Last active April 22, 2019 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a0viedo/6707a836b16621263a31e7bd149bb6d8 to your computer and use it in GitHub Desktop.
Save a0viedo/6707a836b16621263a31e7bd149bb6d8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
const fs = require('fs');
const split2 = require('split2');
let port = Number(process.env.START_PORT);
const list =[];
process.stdin.pipe(split2())
.on('data', p => list.push(p))
.on('end', function() {
const json = JSON.stringify({
ip: process.env.PUBLIC_IP,
list: list.reverse().map((password, index) => {
if(index !== 0) {
port = port + 2;
}
return {port, password};
})
});
fs.writeFileSync('./config.json', json);
console.log('Generated config.json');
});
{
"name": "generate-config-file.js",
"version": "1.0.0",
"description": "",
"bin": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "MIT",
"dependencies": {
"split2": "^3.1.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment