Comparing version 0.5.0 to 0.6.0
27
cli.js
#!/usr/bin/env node | ||
var program = require('commander'); | ||
var fs = require('fs'); | ||
var package = require('./package.json'); | ||
var odesza = require('./'); | ||
'use strict' | ||
const fs = require('fs'); | ||
const program = require('commander'); | ||
const odesza = require('./'); | ||
const app = require('./package.json'); | ||
program | ||
.version(package.version) | ||
.usage('<file> [options]') | ||
.version(app.version) | ||
.usage('<file> [options] var1=val var2=val2]') | ||
.description('Compiles odesza templates.') | ||
@@ -15,5 +17,16 @@ .option('-o, --output', 'output file') | ||
const file = program.args.shift(); | ||
if (program.output) { | ||
const output = program.args.shift(); | ||
} | ||
var template = odesza.compile(program.args[0]); | ||
const vars = {}; | ||
program.args.forEach(arg => { | ||
let parts = arg.split('='); | ||
vars[parts[0]] = parts[1]; | ||
}); | ||
const template = odesza.renderFile(file, vars); | ||
if (program.output) { | ||
@@ -20,0 +33,0 @@ fs.writeFileSync(program.args[1], template); |
{ | ||
"name": "odesza", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "Write clean, expressive templates with just HTML and inline JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -8,2 +8,3 @@ 'use strict'; | ||
const fixture = file => path.join(__dirname, 'fixtures', file); | ||
const exec = require('child_process').exec; | ||
@@ -119,1 +120,9 @@ test('render variable', t => { | ||
}); | ||
test('cli usage with variables', t => { | ||
let vars = { value: 'world' }; | ||
exec('node cli test/fixtures/simple value=world', (err, stdout, stderr) => { | ||
t.ok(stdout == 'hello world', 'rendering file with variables works from the command line'); | ||
t.end(); | ||
}); | ||
}); |
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
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
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
18688
306
1