Skip to content

Commit

Permalink
feat(comments): add comments support to CLI tool
Browse files Browse the repository at this point in the history
  • Loading branch information
RyuuGan committed Jan 5, 2020
1 parent 776d053 commit 3f4ad12
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
8 changes: 6 additions & 2 deletions bin/sol-merger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('<glob> [outputDir]')
.action((_glob, _outputDir) => {
inputGlob = _glob;
Expand All @@ -36,7 +39,8 @@ if (outputDir) {
: path.join(process.cwd(), outputDir);
}

debug(outputDir);
debug('Output directory', outputDir);
debug('With comments?', program.withComments);

glob(
inputGlob,
Expand All @@ -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;
Expand Down
14 changes: 11 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"compileOnSave": false,
"compilerOptions": {
"resolveJsonModule": true,
"sourceMap": true,
"declaration": true,
"outDir": "dist",
Expand Down

0 comments on commit 3f4ad12

Please sign in to comment.