Skip to content

Commit

Permalink
feat(modelOutput): add additional model output path
Browse files Browse the repository at this point in the history
  • Loading branch information
nivekcode committed Mar 15, 2020
1 parent aa52a0e commit 614b37a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"start": "ts-node ./src/bin/svg-to-ts.ts -s './inputfiles/*.svg'",
"start:ofl": "ts-node ./src/bin/svg-to-ts.ts -s './inputfiles/*.svg' --optimizeForLazyLoading true",
"start:ofl:preCompile": "ts-node ./src/bin/svg-to-ts.ts -s './inputfiles/*.svg' --optimizeForLazyLoading true --preCompileSources true",
"start:ofl:preCompile-additionalPath": "ts-node ./src/bin/svg-to-ts.ts -s './inputfiles/*.svg' --optimizeForLazyLoading true --preCompileSources true --additionalModelOutputPath ./additional",
"start:help": "ts-node ./src/bin/svg-to-ts.ts -h",
"start:regex": "ts-node ./src/bin/svg-to-ts.ts -s './inputfilesRegex/**/*.svg'",
"start:kebap": "ts-node ./src/bin/svg-to-ts.ts -s './inputfiles/*.svg' -d KEBAB",
Expand Down
7 changes: 6 additions & 1 deletion src/bin/svg-to-ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,14 @@ commander
'Name of the folder the icons will be generated to (only necessary when optimizeForLazyLoading option is enabled)',
DEFAULT_OPTIONS.iconsFolderName
)
.option(
'--additionalModelOutputPath <string>',
'Additional outputpath for the models file (only helpful when optimizeForLazyLoading option is enabled)',
DEFAULT_OPTIONS.additionalModelOutputPath
)
.option(
'--preCompileSources <boolean>',
'Tells if the sources should be precompiled with the TypeScript compiler. If true, you will only end up with d.ts and js files',
'Tells if the sources should be precompiled with the TypeScript compiler. If true, you will only end up with d.ts and js files (only necessary when optimizeForLazyLoading option is enabled)',
DEFAULT_OPTIONS.preCompileSources
)
.parse(process.argv);
Expand Down
6 changes: 6 additions & 0 deletions src/lib/converters/multiple-files.converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const convertToMultipleFiles = async (convertionOptions: MultiFileConvert
outputDirectory,
srcFiles,
modelFileName,
additionalModelOutputPath,
iconsFolderName,
preCompileSources
} = convertionOptions;
Expand Down Expand Up @@ -71,6 +72,11 @@ export const convertToMultipleFiles = async (convertionOptions: MultiFileConvert
const modelFile = (types += generateInterfaceDefinition(interfaceName, typeName));
await writeFile(`${outputDirectory}/${iconsFolderName}`, modelFileName, modelFile);
info(`model-file successfully generated under ${outputDirectory}/${iconsFolderName}/${modelFileName}.ts`);

if (additionalModelOutputPath) {
await writeFile(`${additionalModelOutputPath}`, modelFileName, modelFile);
info(`additional model-file successfully generated under ${additionalModelOutputPath}/${modelFileName}.ts`);
}
}

if (preCompileSources) {
Expand Down
2 changes: 2 additions & 0 deletions src/lib/options/args-collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const collectArgumentOptions = (): SingleFileConvertionOptions | MultiFil
modelFileName,
iconsFolderName,
optimizeForLazyLoading,
additionalModelOutputPath,
preCompileSources
} = commander;

Expand All @@ -34,6 +35,7 @@ export const collectArgumentOptions = (): SingleFileConvertionOptions | MultiFil
modelFileName,
iconsFolderName,
optimizeForLazyLoading,
additionalModelOutputPath,
preCompileSources
};
};
1 change: 1 addition & 0 deletions src/lib/options/convertion-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface SingleFileConvertionOptions extends ConvertionOptions {

export interface MultiFileConvertionOptions extends ConvertionOptions {
modelFileName: string;
additionalModelOutputPath: string | null;
iconsFolderName: string;
preCompileSources: boolean;
}
Expand Down
6 changes: 2 additions & 4 deletions src/lib/options/default-options.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import { Delimiter } from '../generators/code-snippet-generators';

const DEFAULT_OUTPUT_PATH = './dist';

export const DEFAULT_OPTIONS = {
fileName: 'my-icons',
delimiter: Delimiter.SNAKE,
interfaceName: 'MyIcon',
outputDirectory: DEFAULT_OUTPUT_PATH,
outputDirectory: './dist',
prefix: 'myIcon',
srcFiles: ['*.svg'],
typeName: 'myIcons',
optimizeForLazyLoading: false,
modelOutputPath: DEFAULT_OUTPUT_PATH,
additionalModelOutputPath: null,
modelFileName: 'my-icons.model',
iconsFolderName: 'build',
preCompileSources: false
Expand Down

0 comments on commit 614b37a

Please sign in to comment.