Explorar el Código

CLI: -v option for displaying current version

Fixes #431
tags/v1.2.0
Phillip Johnsen hace 11 años
padre
commit
26a4e95e3b
Se han modificado 2 ficheros con 14 adiciones y 1 borrados
  1. +7
    -1
      bin/mustache
  2. +7
    -0
      test/cli-test.js

+ 7
- 1
bin/mustache Ver fichero

@@ -8,7 +8,7 @@ var pkg = require('../package');
var viewArg = process.argv[2];
var templateArg = process.argv[3];

if (process.argv.indexOf('--version') > -1) {
if (hasVersionArg()) {
return console.log(pkg.version);
}

@@ -87,3 +87,9 @@ function isStdin(viewArg) {
function wasNotFound(err) {
return err.code && err.code === 'ENOENT';
}

function hasVersionArg() {
return ['--version', '-v'].some(function(opt) {
return process.argv.indexOf(opt) > -1;
});
}

+ 7
- 0
test/cli-test.js Ver fichero

@@ -35,6 +35,13 @@ describe('Mustache CLI', function () {
});
});

it('writes module version into stdout when runned with -v', function(done){
exec('bin/mustache -v', function(err, stdout, stderr) {
assert.notEqual(stdout.indexOf(moduleVersion), -1);
done();
});
});

it('writes rendered template into stdout when successfull', function(done) {
exec('bin/mustache test/_files/cli.json test/_files/cli.mustache', function(err, stdout, stderr) {
assert.equal(err, null);


Cargando…
Cancelar
Guardar