@danmasta/interpolate
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -20,20 +20,5 @@ #!/usr/bin/env node | ||
Examples: | ||
envstr -s '{"KEY1":true,"KEY2":false}' --json --quotes`; | ||
envstr -s '{"KEY1":true,"KEY2":false}' --json --quotes | ||
`; | ||
function getStdin () { | ||
let res = ''; | ||
process.stdin.on('data', chunk => { | ||
res += chunk; | ||
}); | ||
return new Promise((resolve, reject) => { | ||
process.stdin.on('end', () => { | ||
resolve(res); | ||
}); | ||
}); | ||
} | ||
function runWithArgv () { | ||
@@ -55,3 +40,3 @@ | ||
console.log(help); | ||
process.stdout.write(help); | ||
@@ -62,16 +47,16 @@ } else { | ||
if (opts.json) { | ||
console.log(envstr.parseJsonStr(opts.string)); | ||
process.stdout.write(envstr.parseJsonStr(opts.string)); | ||
} else { | ||
console.log(envstr.parseTableStr(opts.string)); | ||
process.stdout.write(envstr.parseTableStr(opts.string)); | ||
} | ||
} else if (opts.stdin) { | ||
getStdin().then(str => { | ||
util.getStdin().then(str => { | ||
if (opts.json) { | ||
console.log(envstr.parseJsonStr(str)); | ||
process.stdout.write(envstr.parseJsonStr(str)); | ||
} else { | ||
console.log(envstr.parseTableStr(str)); | ||
process.stdout.write(envstr.parseTableStr(str)); | ||
} | ||
}); | ||
} else { | ||
console.log(help); | ||
process.stdout.write(help); | ||
} | ||
@@ -78,0 +63,0 @@ |
@@ -15,2 +15,3 @@ #!/usr/bin/env node | ||
--string -s - Text string to parse | ||
--stdin - Read from stdin | ||
--env -e - If true will also interpolate from envrionment variables | ||
@@ -25,3 +26,4 @@ --params -p - Stringified json object, or string of key,value pairs: key1=1,key2=2 | ||
Examples: | ||
interpolate -i ./deploy -o ./build --src **/*.(yml|yaml)`; | ||
interpolate -i ./deploy -o ./build --src **/*.(yml|yaml) | ||
`; | ||
@@ -35,2 +37,3 @@ function runWithArgv () { | ||
string: 's', | ||
stdin: null, | ||
env: 'e', | ||
@@ -50,12 +53,16 @@ params: 'p', | ||
console.log(help); | ||
process.stdout.write(help); | ||
} else { | ||
if (opts.string) { | ||
console.log(interpolator.parseStr(opts.string)); | ||
if (opts.stdin) { | ||
util.getStdin().then(str => { | ||
process.stdout.write(interpolator.parseStr(str)); | ||
}); | ||
} else if (opts.string) { | ||
process.stdout.write(interpolator.parseStr(opts.string)); | ||
} else if (opts.input && opts.output) { | ||
interpolator.parseFile(opts.input, opts.output, opts.src); | ||
} else { | ||
console.log(help); | ||
process.stdout.write(help); | ||
} | ||
@@ -62,0 +69,0 @@ |
@@ -35,4 +35,23 @@ const minimist = require('minimist'); | ||
function getStdin () { | ||
return new Promise((resolve, reject) => { | ||
let res = ''; | ||
process.stdin.on('end', () => { | ||
resolve(res); | ||
}); | ||
process.stdin.on('data', chunk => { | ||
res += chunk; | ||
}); | ||
}); | ||
} | ||
exports.isNumeric = isNumeric; | ||
exports.toNativeType = toNativeType; | ||
exports.optsFromArgv = optsFromArgv; | ||
exports.getStdin = getStdin; |
{ | ||
"name": "@danmasta/interpolate", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"author": "Daniel Smith <dannmasta@gmail.com>", | ||
@@ -5,0 +5,0 @@ "description": "Simple string interpolation helper", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13595
278