mirror of
https://github.com/Mibew/simple-icons.git
synced 2024-11-15 09:54:11 +03:00
add deprecation warnings for icons/* imports (#6900)
* add deprecation warnings for icons/* imports * do not log warnings during tests * update message Co-authored-by: Álvaro Mondéjar <mondejar1994@gmail.com> * remove message formatting * add jsdoc deprecation tags * Update scripts/build/package.js Co-authored-by: Álvaro Mondéjar <mondejar1994@gmail.com> * Update scripts/build/package.js Co-authored-by: Álvaro Mondéjar <mondejar1994@gmail.com> * Update scripts/build/package.js Co-authored-by: Álvaro Mondéjar <mondejar1994@gmail.com> * Update scripts/build/package.js Co-authored-by: Álvaro Mondéjar <mondejar1994@gmail.com> * fix "use" for jsdoc Co-authored-by: Álvaro Mondéjar <mondejar1994@gmail.com>
This commit is contained in:
parent
ff9d1e26c4
commit
ec75522f42
@ -94,19 +94,26 @@ data.icons.forEach((icon) => {
|
||||
icons.push(icon);
|
||||
|
||||
const iconObject = iconToObject(icon);
|
||||
const iconExportName = slugToVariableName(icon.slug);
|
||||
|
||||
// write the static .js file for the icon
|
||||
const jsFilepath = path.resolve(iconsDir, `${filename}.js`);
|
||||
writeJs(jsFilepath, `module.exports=${iconObject};`);
|
||||
const newImportMessage = `use "const { ${iconExportName} } = require('simple-icons/icons');" instead`;
|
||||
const message = JSON.stringify(
|
||||
`Imports like "const ${icon.slug} = require('simple-icons/icons/${icon.slug}');" have been deprecated in v6.0.0 and will no longer work from v7.0.0, ${newImportMessage}`,
|
||||
);
|
||||
writeJs(
|
||||
jsFilepath,
|
||||
`console.warn("warn -", ${message});module.exports=${iconObject};`,
|
||||
);
|
||||
|
||||
const dtsFilepath = path.resolve(iconsDir, `${filename}.d.ts`);
|
||||
writeTs(
|
||||
dtsFilepath,
|
||||
'declare const i:import("../alias").I;export default i;',
|
||||
`/**@deprecated ${newImportMessage}*/declare const i:import("../alias").I;export default i;`,
|
||||
);
|
||||
|
||||
// add object to the barrel file
|
||||
const iconExportName = slugToVariableName(icon.slug);
|
||||
iconsBarrelJs.push(`${iconExportName}:${iconObject},`);
|
||||
iconsBarrelMjs.push(`export const ${iconExportName}=${iconObject}`);
|
||||
iconsBarrelDts.push(`export const ${iconExportName}:I;`);
|
||||
|
@ -2,6 +2,8 @@ const { icons } = require('../_data/simple-icons.json');
|
||||
const { getIconSlug } = require('../scripts/utils.js');
|
||||
const testIcon = require('./test-icon.js');
|
||||
|
||||
console.warn = () => {};
|
||||
|
||||
icons.forEach((icon) => {
|
||||
const slug = getIconSlug(icon);
|
||||
const subject = require(`../icons/${slug}.js`);
|
||||
|
Loading…
Reference in New Issue
Block a user