From 40973641a3edd253c6036d3f9cd2584b433e4567 Mon Sep 17 00:00:00 2001 From: Jeffrey Horn Date: Wed, 18 Jan 2017 12:45:44 -0800 Subject: [PATCH] add version flag (#294) * add version flag * set version on the api --- bin/prettier.js | 8 +++++++- index.js | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bin/prettier.js b/bin/prettier.js index 11b81588e..3321b030d 100755 --- a/bin/prettier.js +++ b/bin/prettier.js @@ -13,11 +13,17 @@ const argv = minimist(process.argv.slice(2), { "flow-parser", "bracket-spacing", "single-quote", - "trailing-comma" + "trailing-comma", + "version" ], default: { "bracket-spacing": true } }); +if (argv["version"]) { + console.log(jscodefmt.version); + process.exit(0); +} + const filenames = argv["_"]; const write = argv["write"]; const stdin = argv["stdin"]; diff --git a/index.js b/index.js index d74d07ed1..194f2a936 100644 --- a/index.js +++ b/index.js @@ -3,6 +3,7 @@ const babylon = require("babylon"); const Printer = require("./src/printer").Printer; const flowParser = require("flow-parser"); const comments = require("./src/comments"); +const version = require('./package.json').version; var babylonOptions = { sourceType: "module", @@ -74,5 +75,6 @@ function formatWithShebang(text, opts) { module.exports = { format: function(text, opts) { return formatWithShebang(text, opts); - } + }, + version: version };