소스 검색

Merge pull request #434 from phillipj/feature/cli-v-option

CLI: -v option for displaying current version
tags/v1.2.0
David da Silva Contín 11 년 전
부모
커밋
47ae3b8b49
2개의 변경된 파일14개의 추가작업 그리고 1개의 파일을 삭제
  1. +7
    -1
      bin/mustache
  2. +7
    -0
      test/cli-test.js

+ 7
- 1
bin/mustache 파일 보기

@@ -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 파일 보기

@@ -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);


불러오는 중...
취소
저장