|
1 | 1 | import { BuilderContext, BuilderOutput, createBuilder } from '@angular-devkit/architect'; |
2 | 2 | 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 | | - */ |
7 | 3 | import { |
8 | 4 | CommonConversionOptions, |
9 | 5 | ConstantsConversionOptions, |
10 | 6 | ConversionType, |
11 | 7 | FileConversionOptions, |
12 | 8 | 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'; |
17 | 14 |
|
18 | | -interface Options extends CommonConversionOptions, JsonObject { |
19 | | - generateCompleteIconSet: boolean; // TODO: should this be exportCompleteIconSet |
20 | | -} |
| 15 | +interface Options extends CommonConversionOptions, JsonObject {} |
21 | 16 |
|
22 | | -export default createBuilder<Options>((conversionOptions: Options, context: BuilderContext) => { |
| 17 | +export default createBuilder<Options>((options: Options, context: BuilderContext) => { |
23 | 18 | return new Promise<BuilderOutput>(async (resolve, reject) => { |
24 | 19 | try { |
25 | | - if (!conversionOptions) { |
| 20 | + if (!options.conversionType) { |
26 | 21 | reject(); |
27 | 22 | } |
28 | 23 |
|
| 24 | + const conversionOptions = await mergeWithDefaults(options); |
29 | 25 | if (conversionOptions.conversionType === ConversionType.FILES) { |
30 | 26 | context.logger.info('We are using the conversion type "files"'); |
31 | 27 | await convertToFiles((conversionOptions as unknown) as FileConversionOptions); |
|
0 commit comments