Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 8x 8x 8x 8x | import { Service } from '../../container';
import { writeFileSync } from 'fs';
import { ensureDirSync } from 'fs-extra';
@Service()
export class FileService {
writeEffectTypes(effects: Array<any>) {
const types = `
function strEnum<T extends string>(o: Array<T>): {[K in T]: K} {
return o.reduce((res, key) => {
res[key] = key;
return res;
}, Object.create(null));
}
export const EffectTypes = strEnum(${JSON.stringify(effects).replace(/"/g, `'`).replace(/,/g, ',\n')});
export type EffectTypes = keyof typeof EffectTypes;
`;
const folder = process.env.INTROSPECTION_FOLDER || `./src/app/core/api-introspection/`;
ensureDirSync(folder);
writeFileSync(folder + 'EffectTypes.ts', types, 'utf8');
}
} |