Commit ac86837d authored by 陈帅's avatar 陈帅

fix #2953,prettier support win

parent 4eb06991
/functions/mock/** /functions/mock/**
/scripts
\ No newline at end of file
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
"test": "umi test", "test": "umi test",
"test:component": "umi test ./src/components", "test:component": "umi test ./src/components",
"test:all": "node ./tests/run-tests.js", "test:all": "node ./tests/run-tests.js",
"prettier": "prettier --write './src/**/*'", "prettier": "node node ./scripts/prettier.js",
"docker:dev": "docker-compose -f ./docker/docker-compose.dev.yml up", "docker:dev": "docker-compose -f ./docker/docker-compose.dev.yml up",
"docker:build": "docker-compose -f ./docker/docker-compose.dev.yml build", "docker:build": "docker-compose -f ./docker/docker-compose.dev.yml build",
"docker-prod:dev": "docker-compose -f ./docker/docker-compose.yml up", "docker-prod:dev": "docker-compose -f ./docker/docker-compose.yml up",
......
/**
* copy to https://github.com/facebook/react/blob/master/scripts/prettier/index.js
* prettier api doc https://prettier.io/docs/en/api.html
*----------*****--------------
* prettier all js and all ts.
*----------*****--------------
*/
const glob = require('glob');
const prettier = require('prettier');
const fs = require('fs');
const prettierConfigPath = require.resolve('../.prettierrc');
let didError = false;
let files = [];
const jsFiles = glob.sync('src/**/*.js*', { ignore: ['**/node_modules/**', 'build/**'] });
const tsFiles = glob.sync('src/**/*.ts*', { ignore: ['**/node_modules/**', 'build/**'] });
files = files.concat(jsFiles);
files = files.concat(tsFiles);
if (!files.length) {
return;
}
files.forEach(async file => {
const options = prettier.resolveConfig.sync(file, {
config: prettierConfigPath,
});
const fileInfo = await prettier.getFileInfo(file);
try {
const input = fs.readFileSync(file, 'utf8');
const withParserOptions = {
...options,
parser: fileInfo.inferredParser,
};
const output = prettier.format(input, withParserOptions);
if (output !== input) {
fs.writeFileSync(file, output, 'utf8');
console.log(`\x1b[34m ${file} is prettier`);
}
} catch (e) {
didError = true;
}
});
console.log('\x1b[32m prettier success!');
if (didError) {
process.exit(1);
}
...@@ -22,9 +22,8 @@ const DescriptionList = ({ ...@@ -22,9 +22,8 @@ const DescriptionList = ({
<div className={clsString} {...restProps}> <div className={clsString} {...restProps}>
{title ? <div className={styles.title}>{title}</div> : null} {title ? <div className={styles.title}>{title}</div> : null}
<Row gutter={gutter}> <Row gutter={gutter}>
{React.Children.map( {React.Children.map(children, child =>
children, child ? React.cloneElement(child, { column }) : child
child => (child ? React.cloneElement(child, { column }) : child)
)} )}
</Row> </Row>
</div> </div>
......
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
{ {
"src": "icons/icon-192x192.png", "src": "icons/icon-192x192.png",
"sizes": "192x192" "sizes": "192x192"
},{ },
{
"src": "icons/icon-128x128.png", "src": "icons/icon-128x128.png",
"sizes": "128x128" "sizes": "128x128"
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment