Skip to content

Commit 94bd99f

Browse files
committed
feat: 🎸 enrich options with default options
1 parent 0519928 commit 94bd99f

File tree

3 files changed

+78
-40
lines changed

3 files changed

+78
-40
lines changed

package-lock.json

Lines changed: 67 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"dependencies": {
2121
"@angular-devkit/core": "^10.1.6",
2222
"@angular-devkit/schematics": "^10.1.6",
23-
"typescript": "~4.0.2",
24-
"svg-to-ts": "^5.6.1"
23+
"svg-to-ts": "^5.7.0",
24+
"typescript": "~4.0.2"
2525
},
2626
"devDependencies": {
2727
"@angular-devkit/architect": "^0.1001.7",

svg-icons-builder/index.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,27 @@
11
import { BuilderContext, BuilderOutput, createBuilder } from '@angular-devkit/architect';
22
import { JsonObject } from '@angular-devkit/core';
3-
/*
4-
TODO - we should export this from svg-to-ts - otherwise we rely on internals and it would break if
5-
we refactor something in svg-to-ts
6-
*/
73
import {
84
CommonConversionOptions,
95
ConstantsConversionOptions,
106
ConversionType,
117
FileConversionOptions,
128
ObjectConversionOptions,
13-
} from 'svg-to-ts/src/lib/options/conversion-options';
14-
import { convertToFiles } from 'svg-to-ts/src/lib/converters/files.converter';
15-
import { convertToConstants } from 'svg-to-ts/src/lib/converters/constants.converter';
16-
import { convertToSingleObject } from 'svg-to-ts/src/lib/converters/object.converter';
9+
convertToFiles,
10+
convertToConstants,
11+
convertToSingleObject,
12+
mergeWithDefaults,
13+
} from 'svg-to-ts';
1714

18-
interface Options extends CommonConversionOptions, JsonObject {
19-
generateCompleteIconSet: boolean; // TODO: should this be exportCompleteIconSet
20-
}
15+
interface Options extends CommonConversionOptions, JsonObject {}
2116

22-
export default createBuilder<Options>((conversionOptions: Options, context: BuilderContext) => {
17+
export default createBuilder<Options>((options: Options, context: BuilderContext) => {
2318
return new Promise<BuilderOutput>(async (resolve, reject) => {
2419
try {
25-
if (!conversionOptions) {
20+
if (!options.conversionType) {
2621
reject();
2722
}
2823

24+
const conversionOptions = await mergeWithDefaults(options);
2925
if (conversionOptions.conversionType === ConversionType.FILES) {
3026
context.logger.info('We are using the conversion type "files"');
3127
await convertToFiles((conversionOptions as unknown) as FileConversionOptions);

0 commit comments

Comments
 (0)