From 3f4ad12bb662b544d0bd9243107de5fcb07b1c3f Mon Sep 17 00:00:00 2001 From: Valery Aligorsky Date: Sun, 5 Jan 2020 01:00:13 +0100 Subject: [PATCH] feat(comments): add comments support to CLI tool --- bin/sol-merger.ts | 8 ++++++-- package-lock.json | 14 +++++++++++--- package.json | 2 +- tsconfig.json | 1 + 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/bin/sol-merger.ts b/bin/sol-merger.ts index a217220..e24fdd5 100644 --- a/bin/sol-merger.ts +++ b/bin/sol-merger.ts @@ -8,13 +8,16 @@ import Debug from 'debug'; import { Merger } from '../lib/merger'; import { done } from '../utils/done'; import program from 'commander'; +import { version } from '../package.json'; const debug = Debug('sol-merger:debug'); let inputGlob: string, outputDir: string, append: string; program + .version(`v${version}`, '-v, --version') .option('-a, --append [append]', '', /^([a-zA-Z_]+)$/) + .option('-c, --with-comments', `Doesn't remove comment from exports`, false) .arguments(' [outputDir]') .action((_glob, _outputDir) => { inputGlob = _glob; @@ -36,7 +39,8 @@ if (outputDir) { : path.join(process.cwd(), outputDir); } -debug(outputDir); +debug('Output directory', outputDir); +debug('With comments?', program.withComments); glob( inputGlob, @@ -60,7 +64,7 @@ async function execute(err: Error, files: string[]) { } const promises = files.map(async (file) => { - const merger = new Merger({ delimeter: '\n\n' }); + const merger = new Merger({ delimeter: '\n\n', removeComments: !program.withComments }); let result: string; result = await merger.processFile(file, true); let outputFile: string; diff --git a/package-lock.json b/package-lock.json index 12ace24..5e4742b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -219,9 +219,9 @@ "dev": true }, "commander": { - "version": "2.19.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz", - "integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==" + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-4.0.1.tgz", + "integrity": "sha512-IPF4ouhCP+qdlcmCedhxX4xiGBPyigb8v5NeUp+0LyhwLgxMqyp3S0vl7TAPfS/hiP7FC3caI/PB9lTmP8r1NA==" }, "concat-map": { "version": "0.0.1", @@ -1172,6 +1172,14 @@ "semver": "^5.3.0", "tslib": "^1.8.0", "tsutils": "^2.29.0" + }, + "dependencies": { + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true + } } }, "tsutils": { diff --git a/package.json b/package.json index f363585..7b03b79 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "license": "BSD-2-Clause", "dependencies": { "cli-color": "^1.4.0", - "commander": "^2.19.0", + "commander": "^4.0.1", "debug": "^4.1.1", "fs-extra": "^8.0.1", "glob": "^7.1.2", diff --git a/tsconfig.json b/tsconfig.json index 6a98fa3..99cc331 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,7 @@ { "compileOnSave": false, "compilerOptions": { + "resolveJsonModule": true, "sourceMap": true, "declaration": true, "outDir": "dist",