Skip to content

Commit

Permalink
feat(binaries): provide new binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
nivekcode committed Feb 2, 2022
1 parent f2e4485 commit cd8ddc0
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
}
},
"bin": {
"svg-to-ts-files": "./src/bin/svg-to-ts.js",
"svg-to-ts-consts": "./src/bin/svg-to-ts.js",
"svg-to-ts-object": "./src/bin/svg-to-ts.js"
"svg-to-ts-files": "./src/bin/svg-to-ts-files.js",
"svg-to-ts-constants": "./src/bin/svg-to-ts-constants.js",
"svg-to-ts-object": "./src/bin/svg-to-ts-object.js"
},
"keywords": [
"SVG",
Expand Down
4 changes: 1 addition & 3 deletions src/lib/helpers/logger.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import chalk from 'chalk';

import { DEFAULT_OPTIONS } from '../options/default-options';

export const messagePrefix = 'svg-to-ts:';

export class Logger {
private static verbose = DEFAULT_OPTIONS.verbose;
private static verbose = false;

public static changeVisibility(verbose: boolean) {
Logger.verbose = verbose;
Expand Down
2 changes: 2 additions & 0 deletions src/lib/options/commander/constant-options.commander.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,5 @@ export const setupConstantOptionsCommander = () => {
)
.parse(process.argv);
};

export const getConfigPath = (): string | undefined => commander.config;
2 changes: 2 additions & 0 deletions src/lib/options/commander/file-options.commander.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,5 @@ export const setupFilesOptionsCommander = () => {
)
.parse(process.argv);
};

export const getConfigPath = (): string | undefined => commander.config;
3 changes: 2 additions & 1 deletion src/lib/options/commander/object-options.commander.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import commander from 'commander';

import * as packgeJSON from '../../../../package.json';
import { Delimiter } from '../../generators/code-snippet-generators';
import { DEFAULT_OPTIONS } from '../default-options';
import { DEFAULT_OBJECT_CONVERSION_OPTIONS } from '../default-options/default-object-conversion-options';

export const setupObjectOptionsCommander = () => {
Expand Down Expand Up @@ -36,3 +35,5 @@ export const setupObjectOptionsCommander = () => {
)
.parse(process.argv);
};

export const getConfigPath = (): string | undefined => commander.config;
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import commander from 'commander';

import { getSvgoConfig } from '../../../helpers/svg-optimization';
import { ConstantsConversionOptions } from '../../conversion-options';
import { DEFAULT_OPTIONS } from '../../default-options';
import { ConstantsConversionOptions } from '../../conversion-options/constant-conversion-options';
import { DEFAULT_CONST_CONVERSION_OPTIONS } from '../../default-options/default-constants-conversion-options';

import { toBoolean } from './command-line-collector.helpers';

export const collectCommandLineConstantOptions = async (): Promise<ConstantsConversionOptions> => {
let {
conversionType,
delimiter,
fileName,
interfaceName,
Expand All @@ -22,21 +21,20 @@ export const collectCommandLineConstantOptions = async (): Promise<ConstantsConv
verbose
} = commander;
let svgoConfig = commander.svgoConfig;
generateType = toBoolean(generateType, DEFAULT_OPTIONS.generateType);
generateTypeObject = toBoolean(generateTypeObject, DEFAULT_OPTIONS.generateTypeObject);
generateEnum = toBoolean(generateEnum, DEFAULT_OPTIONS.generateTypeObject);
verbose = toBoolean(verbose, DEFAULT_OPTIONS.verbose);
generateType = toBoolean(generateType, DEFAULT_CONST_CONVERSION_OPTIONS.generateType);
generateTypeObject = toBoolean(generateTypeObject, DEFAULT_CONST_CONVERSION_OPTIONS.generateTypeObject);
generateEnum = toBoolean(generateEnum, DEFAULT_CONST_CONVERSION_OPTIONS.generateTypeObject);
verbose = toBoolean(verbose, DEFAULT_CONST_CONVERSION_OPTIONS.verbose);

// Because of commander adding default value to params
// See: https://stackoverflow.com/questions/30238654/commander-js-collect-multiple-options-always-include-default
let srcFiles = commander.srcFiles;
if (srcFiles.length === 0) {
srcFiles = DEFAULT_OPTIONS.srcFiles;
srcFiles = DEFAULT_CONST_CONVERSION_OPTIONS.srcFiles;
}
svgoConfig = await getSvgoConfig(svgoConfig);

return {
conversionType,
delimiter,
fileName,
enumName,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
import commander from 'commander';

import { getSvgoConfig } from '../../../helpers/svg-optimization';
import { ObjectConversionOptions } from '../../conversion-options';
import { DEFAULT_OPTIONS } from '../../default-options';
import { ObjectConversionOptions } from '../../conversion-options/object-conversion-options';
import { DEFAULT_OBJECT_CONVERSION_OPTIONS } from '../../default-options/default-object-conversion-options';

import { toBoolean } from './command-line-collector.helpers';

export const collectCommandLineObjectOptions = async (): Promise<ObjectConversionOptions> => {
let { conversionType, objectName, delimiter, fileName, outputDirectory, verbose } = commander;
let { objectName, delimiter, fileName, outputDirectory, verbose } = commander;
let svgoConfig = commander.svgoConfig;

// Parse boolean values
verbose = toBoolean(verbose, DEFAULT_OPTIONS.verbose);
verbose = toBoolean(verbose, DEFAULT_OBJECT_CONVERSION_OPTIONS.verbose);

let srcFiles = commander.srcFiles;
if (srcFiles.length === 0) {
srcFiles = DEFAULT_OPTIONS.srcFiles;
srcFiles = DEFAULT_OBJECT_CONVERSION_OPTIONS.srcFiles;
}
svgoConfig = await getSvgoConfig(svgoConfig);

return {
conversionType,
delimiter,
srcFiles,
outputDirectory,
Expand Down

0 comments on commit cd8ddc0

Please sign in to comment.