Skip to content

Commit

Permalink
Unify non-icon exports in svg/font indices
Browse files Browse the repository at this point in the history
  • Loading branch information
MLoughry committed Feb 20, 2024
1 parent e195af7 commit c1690bc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
12 changes: 12 additions & 0 deletions packages/react-icons/addRexportsToIndex.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = function addRexportsToIndex(indexContents) {
indexContents.push('export { FluentIconsProps } from \'./utils/FluentIconsProps.types\'');
indexContents.push('export { default as wrapIcon } from \'./utils/wrapIcon\'');
indexContents.push('export { default as bundleIcon } from \'./utils/bundleIcon\'');
indexContents.push('export { createFluentIcon } from \'./utils/createFluentIcon\'');
indexContents.push('export { createFluentFontIcon } from \'../utils/fonts/createFluentFontIcon\'');
indexContents.push('export type { FluentIcon } from \'./utils/createFluentIcon\'');
indexContents.push('export * from \'./utils/useIconState\'');
indexContents.push('export * from \'./utils/constants\'');
indexContents.push('export { IconDirectionContextProvider, useIconContext } from \'./contexts/index\'');
indexContents.push('export type { IconDirectionContextValue } from \'./contexts/index\'');
}
11 changes: 2 additions & 9 deletions packages/react-icons/convert-font.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const mkdirp = require('mkdirp');
const { promisify } = require('util');
const { option } = require("yargs");
const glob = promisify(require('glob'));
const addRexportsToIndex = require('./addRexportsToIndex');

// @ts-ignore
const SRC_PATH = argv.source;
Expand Down Expand Up @@ -69,15 +70,7 @@ async function processFiles(src, dest) {

const indexPath = path.join(dest, 'index.tsx')
// Finally add the interface definition and then write out the index.
indexContents.push('export { FluentIconsProps } from \'../utils/FluentIconsProps.types\'');
indexContents.push('export { default as wrapIcon } from \'../utils/wrapIcon\'');
indexContents.push('export { default as bundleIcon } from \'../utils/bundleIcon\'');
indexContents.push('export { createFluentFontIcon } from \'../utils/fonts/createFluentFontIcon\'');
indexContents.push('export type { FluentIcon } from \'../utils/createFluentIcon\'');
indexContents.push('export * from \'../utils/useIconState\'');
indexContents.push('export * from \'../utils/constants\'');
indexContents.push('export { IconDirectionContextProvider, useIconContext } from \'../contexts/index\'');
indexContents.push('export type { IconDirectionContextValue } from \'../contexts/index\'');
addRexportsToIndex(indexContents);


await fs.writeFile(indexPath, indexContents.join('\n'));
Expand Down
12 changes: 2 additions & 10 deletions packages/react-icons/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const fs = require("fs");
const path = require("path");
const argv = require("yargs").boolean("selector").default("selector", false).argv;
const _ = require("lodash");
const addRexportsToIndex = require('./addRexportsToIndex');

const SRC_PATH = argv.source;
const DEST_PATH = argv.dest;
Expand Down Expand Up @@ -68,20 +69,11 @@ function processFiles(src, dest) {

const indexPath = path.join(dest, 'index.tsx')
// Finally add the interface definition and then write out the index.
indexContents.push('export { FluentIconsProps } from \'./utils/FluentIconsProps.types\'');
indexContents.push('export { default as wrapIcon } from \'./utils/wrapIcon\'');
indexContents.push('export { default as bundleIcon } from \'./utils/bundleIcon\'');
indexContents.push('export { createFluentIcon } from \'./utils/createFluentIcon\'');
indexContents.push('export type { FluentIcon } from \'./utils/createFluentIcon\'');
indexContents.push('export * from \'./utils/useIconState\'');
indexContents.push('export * from \'./utils/constants\'');
indexContents.push('export { IconDirectionContextProvider, useIconContext } from \'./contexts/index\'');
indexContents.push('export type { IconDirectionContextValue } from \'./contexts/index\'');
addRexportsToIndex(indexContents);

fs.writeFileSync(indexPath, indexContents.join('\n'), (err) => {
if (err) throw err;
});

}

/**
Expand Down

0 comments on commit c1690bc

Please sign in to comment.