kopia lustrzana https://github.com/shoelace-style/shoelace
don't swallow errors
rodzic
c37e4ba6b5
commit
ca8ba2d16b
|
@ -16,35 +16,29 @@ const iconDir = path.join(outdir, '/assets/icons');
|
|||
|
||||
const iconPackageData = JSON.parse(await fs.readFile('./node_modules/bootstrap-icons/package.json', 'utf8'));
|
||||
|
||||
const version = iconPackageData.version;
|
||||
const srcPath = `./.cache/icons/icons-${version}`;
|
||||
const url = `https://github.com/twbs/icons/archive/v${version}.zip`;
|
||||
|
||||
try {
|
||||
const version = iconPackageData.version;
|
||||
const srcPath = `./.cache/icons/icons-${version}`;
|
||||
const url = `https://github.com/twbs/icons/archive/v${version}.zip`;
|
||||
|
||||
try {
|
||||
await fs.stat(`${srcPath}/LICENSE.md`);
|
||||
} catch {
|
||||
} catch {
|
||||
// Download the source from GitHub (since not everything is published to NPM)
|
||||
console.log(`Downloading and extracting Bootstrap Icons ${version}...`);
|
||||
await download(url, './.cache/icons', { extract: true });
|
||||
}
|
||||
}
|
||||
|
||||
// Copy icons
|
||||
console.log(`Copying icons and license...`);
|
||||
await deleteAsync([iconDir]);
|
||||
await fs.mkdir(iconDir, { recursive: true });
|
||||
await Promise.all([
|
||||
// Copy icons
|
||||
await deleteAsync([iconDir]);
|
||||
await fs.mkdir(iconDir, { recursive: true });
|
||||
await Promise.all([
|
||||
copy(`${srcPath}/icons`, iconDir),
|
||||
copy(`${srcPath}/LICENSE.md`, path.join(iconDir, 'LICENSE.md')),
|
||||
copy(`${srcPath}/bootstrap-icons.svg`, './docs/assets/images/sprite.svg', { overwrite: true })
|
||||
]);
|
||||
]);
|
||||
|
||||
// Generate metadata
|
||||
const files = await globby(`${srcPath}/docs/content/icons/**/*.md`);
|
||||
|
||||
console.log(`Generating metadata for ${files.length} icons...`);
|
||||
|
||||
const metadata = await Promise.all(
|
||||
// Generate metadata
|
||||
const files = await globby(`${srcPath}/docs/content/icons/**/*.md`);
|
||||
const metadata = await Promise.all(
|
||||
files.map(async file => {
|
||||
const name = path.basename(file, path.extname(file));
|
||||
const data = fm(await fs.readFile(file, 'utf8')).attributes;
|
||||
|
@ -56,9 +50,6 @@ try {
|
|||
tags: data.tags
|
||||
};
|
||||
})
|
||||
);
|
||||
);
|
||||
|
||||
await fs.writeFile(path.join(iconDir, 'icons.json'), JSON.stringify(metadata, null, 2), 'utf8');
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
await fs.writeFile(path.join(iconDir, 'icons.json'), JSON.stringify(metadata, null, 2), 'utf8');
|
||||
|
|
|
@ -18,14 +18,13 @@ const embeds = {};
|
|||
|
||||
mkdirSync(themesDir, { recursive: true });
|
||||
|
||||
try {
|
||||
// Gather an object containing the source of all files named "_filename.css" so we can embed them later
|
||||
filesToEmbed.forEach(file => {
|
||||
// Gather an object containing the source of all files named "_filename.css" so we can embed them later
|
||||
filesToEmbed.forEach(file => {
|
||||
embeds[path.basename(file)] = fs.readFileSync(file, 'utf8');
|
||||
});
|
||||
});
|
||||
|
||||
// Loop through each theme file, copying the .css and generating a .js version for Lit users
|
||||
files.forEach(file => {
|
||||
// Loop through each theme file, copying the .css and generating a .js version for Lit users
|
||||
files.forEach(file => {
|
||||
let source = fs.readFileSync(file, 'utf8');
|
||||
|
||||
// If the source has "/* _filename.css */" in it, replace it with the embedded styles
|
||||
|
@ -53,8 +52,4 @@ try {
|
|||
|
||||
fs.writeFileSync(cssFile, css, 'utf8');
|
||||
fs.writeFileSync(jsFile, js, 'utf8');
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(chalk.red('Error generating stylesheets!'));
|
||||
console.error(err);
|
||||
}
|
||||
});
|
||||
|
|
Ładowanie…
Reference in New Issue