mirror of https://github.com/alibaba/ice.git
parent
87ffdc071e
commit
d360264b34
|
|
@ -35,13 +35,19 @@ export default class Generator {
|
||||||
|
|
||||||
private projectRoot: string;
|
private projectRoot: string;
|
||||||
|
|
||||||
constructor({ projectRoot, targetDir, templateDir, defaultData }) {
|
private log: any;
|
||||||
|
|
||||||
|
private showPrettierError: boolean;
|
||||||
|
|
||||||
|
constructor({ projectRoot, targetDir, templateDir, defaultData, log }) {
|
||||||
this.projectRoot = projectRoot;
|
this.projectRoot = projectRoot;
|
||||||
this.templateDir = templateDir;
|
this.templateDir = templateDir;
|
||||||
this.targetDir = targetDir;
|
this.targetDir = targetDir;
|
||||||
this.renderData = defaultData;
|
this.renderData = defaultData;
|
||||||
this.contentRegistration = {};
|
this.contentRegistration = {};
|
||||||
this.rerender = false;
|
this.rerender = false;
|
||||||
|
this.log = log;
|
||||||
|
this.showPrettierError = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public addExport = (registerKey ,exportData: IExportData|IExportData[]) => {
|
public addExport = (registerKey ,exportData: IExportData|IExportData[]) => {
|
||||||
|
|
@ -136,7 +142,10 @@ export default class Generator {
|
||||||
singleQuote: true
|
singleQuote: true
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
if (this.showPrettierError) {
|
||||||
|
this.log.warn(`Prettier format error: ${error.message}`);
|
||||||
|
this.showPrettierError = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fse.ensureDirSync(path.dirname(targetPath));
|
fse.ensureDirSync(path.dirname(targetPath));
|
||||||
fse.writeFileSync(targetPath, content, 'utf-8');
|
fse.writeFileSync(targetPath, content, 'utf-8');
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import getPages from './utils/getPages';
|
||||||
import formatPath from './utils/formatPath';
|
import formatPath from './utils/formatPath';
|
||||||
|
|
||||||
export default (api) => {
|
export default (api) => {
|
||||||
const { onHook, onGetWebpackConfig, registerMethod, registerUserConfig, context, getAllPlugin, setValue, modifyUserConfig } = api;
|
const { onHook, onGetWebpackConfig, registerMethod, registerUserConfig, context, getAllPlugin, setValue, modifyUserConfig, log } = api;
|
||||||
const { rootDir, command, userConfig } = context;
|
const { rootDir, command, userConfig } = context;
|
||||||
|
|
||||||
const iceTempPath = path.join(rootDir, '.ice');
|
const iceTempPath = path.join(rootDir, '.ice');
|
||||||
|
|
@ -113,7 +113,8 @@ export default (api) => {
|
||||||
defaultData: {
|
defaultData: {
|
||||||
runtimeModules,
|
runtimeModules,
|
||||||
buildConfig: JSON.stringify(buildConfig)
|
buildConfig: JSON.stringify(buildConfig)
|
||||||
}
|
},
|
||||||
|
log
|
||||||
});
|
});
|
||||||
|
|
||||||
const pageGenerator = new PageGenerator({
|
const pageGenerator = new PageGenerator({
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue