Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const tasks = [
'yarn format:diff',
'yarn lint --quiet',
'yarn lint:docs',
`yarn bundler check --ignore '**/@(node_modules|examples|components|react|fixtures)/**' 'packages/**/*.scss'`,
`cross-env BABEL_ENV=test yarn test --ci --maxWorkers 2 --reporters=default --reporters=jest-junit`,
`cross-env BABEL_ENV=test yarn test:e2e --ci --maxWorkers 2 --reporters=default --reporters=jest-junit`,
];
try {
for (const task of tasks) {
const now = Date.now();
reporter.info(`Running: ${task}`);
await exec(task, options);
reporter.success(`Done in: ${Date.now() - now}ms`);
}
} catch (error) {
console.log(error.stdout);
console.log(error.stderr);
console.log(error);
process.exit(1);
}
}
if (errors.length > 0) {
errors.forEach(error => {
const { formatted, file } = error;
reporter.error(`Error compiling ${path.relative(cwd, file)}`);
console.log(chalk.gray(formatted));
});
process.exit(1);
return;
}
if (list) {
reporter.info('Compiled the following files:');
console.log(files);
}
reporter.success(`Successfully compiled ${files.length} files! 🎉`);
process.exit(0);
}
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);
}
reporter.success('Done! 🎉');
}
themes,
tokens,
defaultTheme,
defaultThemeMapName
);
},
},
];
await fs.ensureDir(SCSS_DIR);
for (const { filepath, builder } of files) {
const { code } = generate(builder());
await fs.writeFile(filepath, code);
}
reporter.success('Done! 🎉');
}
);
})
);
reporter.info('Generating Storybook stories...');
await fs.remove(STORYBOOK_DIR);
await fs.ensureDir(STORYBOOK_DIR);
await Promise.all(
meta.map(info => {
const { moduleName } = info;
const outputPath = path.join(STORYBOOK_DIR, `${moduleName}-story.js`);
return fs.writeFile(outputPath, createIconStory(info));
})
);
reporter.success('Done! 🎉');
}
}
return acc + '\n' + `$${name}: ${value};`;
}, '');
const COLOR_IMPORT = `@import 'colors';`;
await fs.writeFile(
TOKEN_ENTRYPOINT,
prettier.format(
GENERATED_COMMENT + '\n' + COLOR_IMPORT + '\n' + tokenSource,
prettierOptions
)
);
reporter.success('Done! 🎉');
}
await bundle.write(outputOptions);
})
);
reporter.info('Generating Storybook stories...');
await fs.remove(STORYBOOK_DIR);
await fs.ensureDir(STORYBOOK_DIR);
await Promise.all(
meta.map(info => {
const { moduleName } = info;
const outputPath = path.join(STORYBOOK_DIR, `${moduleName}-story.js`);
return fs.writeFile(outputPath, createIconStory(info));
})
);
reporter.success('Done! 🎉');
}
const optimized = await flatMapAsync(files, async file => {
const { filepath } = file;
const source = await fs.readFile(filepath);
const optimized = await svgo.optimize(source, {
path: filepath,
});
return {
...file,
source,
optimized,
};
});
reporter.success(`Successfully optimized ${optimized.length} icons 🎉`);
return optimized;
}
if (relativePath.includes('node_modules')) {
return false;
}
if (relativePath[0] === '.') {
return false;
}
return true;
},
});
reporter.success(
`Built example \`${example.name}\` in package \`${pkg.name}\``
);
})
);
reporter.success(`Built examples in package \`${pkg.name}\``);
})
);