Browse Source

Fixed merge conflict

es6
Zhenfei.Li-李振飞 2 years ago
parent
commit
d393c6a05e
  1. 57
      es6.js
  2. 3
      package.json

57
es6.js

@ -1,10 +1,26 @@
const fs = require("fs"); const fs = require("fs");
const path = require("path");
const prettier = require("prettier");
const { exec } = require("child_process");
async function fix(path) {
new Promise(res => {
exec(`yarn eslint --fix ${path}`, () => {
res();
});
});
}
const srcName = process.argv[2]; async function handleFile(srcName) {
const sourceCode = fs.readFileSync(srcName).toString(); const sourceCode = fs.readFileSync(srcName).toString();
const clzName = /BI\.(.*?)\s\=\sBI\.inherit\(/.exec(sourceCode)[1]; const result = /BI\.(.*?)\s\=\sBI\.inherit\(/.exec(sourceCode);
if (!result) {
console.log(`可能是已经es6过了 ${srcName}`);
return;
}
const clzName = result[1];
const superName = /inherit\(BI\.(.*?),/.exec(sourceCode)[1]; const superName = /inherit\(BI\.(.*?),/.exec(sourceCode)[1];
@ -139,5 +155,36 @@ ${M}
} }
`; `;
// fs.writeFileSync(`${srcName}.js.raw`, sourceCode); const prettierCode = prettier.format(outputCode);
fs.writeFileSync(srcName, outputCode); fs.writeFileSync(srcName, prettierCode);
await fix(srcName);
return clzName;
}
async function traverse(srcName) {
if (srcName.indexOf("__test__") >= 0) return;
if (srcName.endsWith(".js")) {
return await handleFile(srcName);
} else {
const stat = fs.statSync(srcName);
const flag = stat.isDirectory();
if (flag) {
const files = fs.readdirSync(srcName);
// let indexContent = "";
for (let i = 0; i < files.length; i++) {
const file = files[i];
await traverse(path.resolve(srcName, file));
// const clzName = await traverse(path.resolve(srcName, file));
// const moduleName = path.basename(srcName).replace(/.js$/, "");
// if (clzName) {
// indexContent += `export { ${clzName} } from '${moduleName}'\n`;
// }
}
}
}
}
const srcName = process.argv[2];
traverse(srcName);

3
package.json

@ -25,7 +25,7 @@
"cross-env": "6.0.0", "cross-env": "6.0.0",
"css-loader": "3.0.0", "css-loader": "3.0.0",
"es6-promise": "4.2.8", "es6-promise": "4.2.8",
"eslint": "6.0.1", "eslint": "7.32.0",
"expose-loader": "0.7.5", "expose-loader": "0.7.5",
"express": "4.15.2", "express": "4.15.2",
"fork-ts-checker-webpack-plugin": "1.4.3", "fork-ts-checker-webpack-plugin": "1.4.3",
@ -47,6 +47,7 @@
"optimize-css-assets-webpack-plugin": "5.0.3", "optimize-css-assets-webpack-plugin": "5.0.3",
"postcss-loader": "3.0.0", "postcss-loader": "3.0.0",
"postcss-simple-vars": "5.0.2", "postcss-simple-vars": "5.0.2",
"prettier": "2.8.2",
"puppeteer": "^13.3.0", "puppeteer": "^13.3.0",
"rimraf": "3.0.2", "rimraf": "3.0.2",
"script-loader": "0.7.2", "script-loader": "0.7.2",

Loading…
Cancel
Save