Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions snapshots/iconfont-js/h5/IconAlipay.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable */

import React from 'react';
import { getIconColor } from './helper';

const DEFAULT_STYLE = {
Expand Down
1 change: 1 addition & 0 deletions snapshots/iconfont-js/h5/IconSetup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable */

import React from 'react';
import { getIconColor } from './helper';

const DEFAULT_STYLE = {
Expand Down
1 change: 1 addition & 0 deletions snapshots/iconfont-js/h5/IconUser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable */

import React from 'react';
import { getIconColor } from './helper';

const DEFAULT_STYLE = {
Expand Down
1 change: 1 addition & 0 deletions snapshots/iconfont-js/h5/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable */

import React from 'react';
import IconAlipay from './IconAlipay';
import IconUser from './IconUser';
import IconSetup from './IconSetup';
Expand Down
2 changes: 1 addition & 1 deletion snapshots/iconfont-js/index.alipay.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable */

import React from 'react';
import Taro from '@tarojs/taro';

const IconFont = (props) => {
Expand Down
2 changes: 1 addition & 1 deletion snapshots/iconfont-js/index.h5.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable */

import React from 'react';
import Taro from '@tarojs/taro';
import Icon from './h5';

Expand Down
2 changes: 1 addition & 1 deletion snapshots/iconfont-js/index.qq.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable */

import React from 'react';
import Taro from '@tarojs/taro';

const IconFont = (props) => {
Expand Down
2 changes: 1 addition & 1 deletion snapshots/iconfont-js/index.swan.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable */

import React from 'react';
import Taro from '@tarojs/taro';

const IconFont = (props) => {
Expand Down
2 changes: 1 addition & 1 deletion snapshots/iconfont-js/index.tt.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable */

import React from 'react';
import Taro from '@tarojs/taro';

const IconFont = (props) => {
Expand Down
2 changes: 1 addition & 1 deletion snapshots/iconfont-js/index.weapp.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable */

import React from 'react';
import Taro from '@tarojs/taro';

const IconFont = (props) => {
Expand Down
1 change: 1 addition & 0 deletions snapshots/iconfont-js/rn/IconAlipay.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable */

import React from 'react';
import { Svg, Path } from 'react-native-svg';
import { getIconColor } from './helper';

Expand Down
1 change: 1 addition & 0 deletions snapshots/iconfont-js/rn/IconSetup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable */

import React from 'react';
import { Svg, Path } from 'react-native-svg';
import { getIconColor } from './helper';

Expand Down
1 change: 1 addition & 0 deletions snapshots/iconfont-js/rn/IconUser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable */

import React from 'react';
import { Svg, Path } from 'react-native-svg';
import { getIconColor } from './helper';

Expand Down
1 change: 1 addition & 0 deletions snapshots/iconfont-js/rn/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable */

import React from 'react';

import IconAlipay from './IconAlipay';
import IconUser from './IconUser';
Expand Down
2 changes: 1 addition & 1 deletion snapshots/iconfont-ts/h5/IconAlipay.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* tslint:disable */
/* eslint-disable */

import { CSSProperties, DOMAttributes, FunctionComponent } from 'react';
import React, { CSSProperties, DOMAttributes, FunctionComponent } from 'react';
import { getIconColor } from './helper';

interface Props extends DOMAttributes<SVGElement> {
Expand Down
2 changes: 1 addition & 1 deletion snapshots/iconfont-ts/h5/IconSetup.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* tslint:disable */
/* eslint-disable */

import { CSSProperties, DOMAttributes, FunctionComponent } from 'react';
import React, { CSSProperties, DOMAttributes, FunctionComponent } from 'react';
import { getIconColor } from './helper';

interface Props extends DOMAttributes<SVGElement> {
Expand Down
2 changes: 1 addition & 1 deletion snapshots/iconfont-ts/h5/IconUser.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* tslint:disable */
/* eslint-disable */

import { CSSProperties, DOMAttributes, FunctionComponent } from 'react';
import React, { CSSProperties, DOMAttributes, FunctionComponent } from 'react';
import { getIconColor } from './helper';

interface Props extends DOMAttributes<SVGElement> {
Expand Down
2 changes: 1 addition & 1 deletion snapshots/iconfont-ts/h5/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* tslint:disable */
/* eslint-disable */

import { CSSProperties, DOMAttributes, FunctionComponent } from 'react';
import React, { CSSProperties, DOMAttributes, FunctionComponent } from 'react';
import IconAlipay from './IconAlipay';
import IconUser from './IconUser';
import IconSetup from './IconSetup';
Expand Down
2 changes: 1 addition & 1 deletion snapshots/iconfont-ts/index.alipay.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* tslint:disable */
/* eslint-disable */

import React from 'react';
import Taro, { FunctionComponent } from '@tarojs/taro';

interface Props {
Expand Down
2 changes: 1 addition & 1 deletion snapshots/iconfont-ts/index.h5.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* tslint:disable */
/* eslint-disable */

import React from 'react';
import Taro, { FunctionComponent } from '@tarojs/taro';
import Icon from './h5';

Expand Down
2 changes: 1 addition & 1 deletion snapshots/iconfont-ts/index.qq.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* tslint:disable */
/* eslint-disable */

import React from 'react';
import Taro, { FunctionComponent } from '@tarojs/taro';

interface Props {
Expand Down
2 changes: 1 addition & 1 deletion snapshots/iconfont-ts/index.swan.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* tslint:disable */
/* eslint-disable */

import React from 'react';
import Taro, { FunctionComponent } from '@tarojs/taro';

interface Props {
Expand Down
2 changes: 1 addition & 1 deletion snapshots/iconfont-ts/index.tt.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* tslint:disable */
/* eslint-disable */

import React from 'react';
import Taro, { FunctionComponent } from '@tarojs/taro';

interface Props {
Expand Down
2 changes: 1 addition & 1 deletion snapshots/iconfont-ts/index.weapp.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* tslint:disable */
/* eslint-disable */

import React from 'react';
import Taro, { FunctionComponent } from '@tarojs/taro';

interface Props {
Expand Down
2 changes: 1 addition & 1 deletion snapshots/iconfont-ts/rn/IconAlipay.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* tslint:disable */
/* eslint-disable */

import { FunctionComponent } from 'react';
import React, { FunctionComponent } from 'react';
import { ViewProps } from 'react-native';
import { Svg, GProps, Path } from 'react-native-svg';
import { getIconColor } from './helper';
Expand Down
2 changes: 1 addition & 1 deletion snapshots/iconfont-ts/rn/IconSetup.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* tslint:disable */
/* eslint-disable */

import { FunctionComponent } from 'react';
import React, { FunctionComponent } from 'react';
import { ViewProps } from 'react-native';
import { Svg, GProps, Path } from 'react-native-svg';
import { getIconColor } from './helper';
Expand Down
2 changes: 1 addition & 1 deletion snapshots/iconfont-ts/rn/IconUser.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* tslint:disable */
/* eslint-disable */

import { FunctionComponent } from 'react';
import React, { FunctionComponent } from 'react';
import { ViewProps } from 'react-native';
import { Svg, GProps, Path } from 'react-native-svg';
import { getIconColor } from './helper';
Expand Down
2 changes: 1 addition & 1 deletion snapshots/iconfont-ts/rn/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* tslint:disable */
/* eslint-disable */

import { FunctionComponent } from 'react';
import React, { FunctionComponent } from 'react';
import { ViewProps } from 'react-native';
import { GProps } from 'react-native-svg';
import IconAlipay from './IconAlipay';
Expand Down
26 changes: 13 additions & 13 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { PLATFORM_MAP } from '../libs/maps';
import { filterMiniProgramConfig, filterReactNativeConfig, filterReactWebConfig } from '../libs/filterConfig';
import { generateUsingComponent } from '../libs/generateUsingComponent';
import { getIconNames } from '../libs/getIconNames';
import { replaceDuplicateReact } from '../libs/replace';
// import { replaceDuplicateReact } from '../libs/replace';

const basePath = path.join(__dirname, '..');
const miniProgramBasePath = 'node_modules/mini-program-iconfont-cli';
Expand Down Expand Up @@ -70,12 +70,12 @@ fetchXml(config.symbol_url).then((result) => {
execFile = execFile.replace(/react-native-iconfont-cli/, reactNativeDir);
require(execFile)[execMethod](result, filterReactNativeConfig(config, platform));

glob.sync(path.resolve(config.save_dir, platform, '*.{js,tsx}')).map((rnFilePath) => {
fs.writeFileSync(
rnFilePath,
replaceDuplicateReact(fs.readFileSync(rnFilePath).toString())
);
});
// glob.sync(path.resolve(config.save_dir, platform, '*.{js,tsx}')).map((rnFilePath) => {
// fs.writeFileSync(
// rnFilePath,
// replaceDuplicateReact(fs.readFileSync(rnFilePath).toString())
// );
// });
// Remove .d.ts files
glob.sync(path.resolve(config.save_dir, platform, '*.d.ts')).map((rnFilePath) => {
fs.unlinkSync(rnFilePath);
Expand All @@ -84,12 +84,12 @@ fetchXml(config.symbol_url).then((result) => {
execFile = execFile.replace(/react-iconfont-cli/, reactWebDir);
require(execFile)[execMethod](result, filterReactWebConfig(config, platform));

glob.sync(path.resolve(config.save_dir, platform, '*.{js,tsx}')).map((h5FilePath) => {
fs.writeFileSync(
h5FilePath,
replaceDuplicateReact(fs.readFileSync(h5FilePath).toString())
);
});
// glob.sync(path.resolve(config.save_dir, platform, '*.{js,tsx}')).map((h5FilePath) => {
// fs.writeFileSync(
// h5FilePath,
// replaceDuplicateReact(fs.readFileSync(h5FilePath).toString())
// );
// });
// Remove .d.ts files
glob.sync(path.resolve(config.save_dir, platform, '*.d.ts')).map((h5FilePath) => {
fs.unlinkSync(h5FilePath);
Expand Down
12 changes: 6 additions & 6 deletions src/libs/replace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ export const replacePlatform = (content: string, platform: string) => {
return content.replace(/#platform#/g, platform);
};

export const replaceDuplicateReact = (content: string) => {
return content
// Taro will inject React into file automatically.
.replace(/(import)\s+React(\s*,)/, '$1')
.replace(/import\s+React\s+from\s+'react';\n/, '')
};
// export const replaceDuplicateReact = (content: string) => {
// return content
// // Taro will inject React into file automatically.
// .replace(/(import)\s+React(\s*,)/, '$1')
// .replace(/import\s+React\s+from\s+'react';\n/, '')
// };

export const replaceIsRpx = (content: string, useRpx: boolean) => {
return content
Expand Down
2 changes: 1 addition & 1 deletion src/templates/index.h5.js.template
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable */

import React from 'react';
import Taro from '@tarojs/taro';
import Icon from './h5';

Expand Down
2 changes: 1 addition & 1 deletion src/templates/index.h5.tsx.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* tslint:disable */
/* eslint-disable */

import React from 'react';
import Taro, { FunctionComponent } from '@tarojs/taro';
import Icon from './h5';

Expand Down
2 changes: 1 addition & 1 deletion src/templates/index.platform.js.template
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable */

import React from 'react';
import Taro from '@tarojs/taro';

const IconFont = (props) => {
Expand Down
2 changes: 1 addition & 1 deletion src/templates/index.platform.tsx.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* tslint:disable */
/* eslint-disable */

import React from 'react';
import Taro, { FunctionComponent } from '@tarojs/taro';

interface Props {
Expand Down