Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function build() {
reporter.log('Cleaning build dirs...');
try {
await clean();
await Promise.all([fs.mkdir(paths.STORIES), fs.mkdir(paths.TS)]);
} catch (err) {
reporter.error(err);
}
reporter.log('Generating source components...');
await generateComponents();
reporter.log('Compiling and generating modules...');
// run the angular compiler over everything
ngc.main(['-p', './config/tsconfig-aot.json']);
reporter.log('Bundling...');
await buildUMD();
// build the storybook examples
reporter.log('Generating storybook examples...');
buildExamples();
}
.replace('es', 'ts')
.replace('.js', '.ts');
// try to write out the component
try {
await fs.ensureDir(dirname(outputPath));
await fs.writeFile(
outputPath,
componentTemplate(
selectorName,
className,
rawSvg,
icon.descriptor.attrs
)
);
} catch (err) {
reporter.error(err);
}
}
}
errors.forEach(error => {
const { formatted, filepath } = error;
reporter.error(`Error compiling ${path.relative(cwd, filepath)}`);
console.log(chalk.gray(formatted));
});
process.exit(1);
async function bundle(entrypoint, options, info) {
const { cwd } = info;
const extension = path.extname(entrypoint);
if (!bundlers.has(extension)) {
reporter.error(
`Invalid extension: \`${extension}\` on entrypoint: \`${entrypoint}\``
);
process.exit(1);
}
try {
const bundle = bundlers.get(extension);
await bundle(path.join(cwd, entrypoint), options, info);
} catch (error) {
reporter.error(`Unexpected error occurred while bundling ${entrypoint}:`);
console.log(error);
process.exit(1);
}
reporter.success('Done! 🎉');
}
errors.forEach(error => {
const { formatted, file } = error;
reporter.error(`Error compiling ${path.relative(cwd, file)}`);
console.log(chalk.gray(formatted));
});
process.exit(1);
const files = await glob(pattern, {
cwd,
ignore,
});
if (json) {
reporter.info(
`Creating sassdoc json for pattern: '${pattern}', ignoring: '${ignore}'`
);
try {
const jsonFile = await createJson(files);
await fs.ensureDir(DOCS_DIR);
await fs.writeFile(JSON_FILE, JSON.stringify(jsonFile, null, 2));
} catch (error) {
reporter.error(`Sassdoc error: ${error}`);
process.exit(1);
}
reporter.success('Done! 🎉');
} else {
reporter.info(
`Creating sassdoc markdown for pattern: '${pattern}', ignoring: '${ignore}'`
);
try {
const markdownFile = await createMarkdown(files);
await fs.ensureDir(DOCS_DIR);
await fs.writeFile(MARKDOWN_FILE, markdownFile);
} catch (error) {
reporter.error(`Sassdoc error: ${error}`);
process.exit(1);