Skip to content

Commit 0a3f62c

Browse files
hsuanxyzvthinkxie
authored andcommitted
feat(schematics): do not set boot page when the target file is modified (#3178)
1 parent c685836 commit 0a3f62c

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

schematics/ng-add/schema.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
"default": false,
1717
"description": "Do not add ng-zorro-antd dependencies to package.json (e.g., --skipPackageJson)"
1818
},
19+
"bootPage": {
20+
"type": "boolean",
21+
"default": true,
22+
"description": "Set up boot page."
23+
},
1924
"dynamicIcon": {
2025
"type": "boolean",
2126
"default": false,
@@ -124,13 +129,7 @@
124129
"type": "boolean",
125130
"default": true,
126131
"description": "Whether Angular browser animations should be set up."
127-
},
128-
"bootPage": {
129-
"type": "boolean",
130-
"default": true,
131-
"description": "Whether boot page should be set up.",
132-
"x-prompt": "Set up the boot page"
133132
}
134133
},
135134
"required": []
136-
}
135+
}

schematics/ng-generate/boot-page/index.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import { Rule, Tree } from '@angular-devkit/schematics';
22
import { getProjectFromWorkspace } from '@angular/cdk/schematics';
33
import { getWorkspace } from '@schematics/angular/utility/config';
44
import chalk from 'chalk';
5+
import { statSync as fsStatSync } from 'fs';
56
import { Schema } from './schema';
67

78
const bootPageHTML = `<!-- NG-ZORRO -->
89
<a href="https://github.com/NG-ZORRO/ng-zorro-antd" target="_blank" style="display: flex;align-items: center;justify-content: center;height: 100%;width: 100%;">
910
<img height="300" src="https://img.alicdn.com/tfs/TB1X.qJJgHqK1RjSZFgXXa7JXXa-89-131.svg">
1011
</a>`;
1112

12-
export default function (options: Schema): Rule {
13+
export default function(options: Schema): Rule {
1314
return (host: Tree) => {
1415
const workspace = getWorkspace(host);
1516
const project = getProjectFromWorkspace(workspace, options.project);
@@ -18,11 +19,16 @@ export default function (options: Schema): Rule {
1819

1920
if (!buffer) {
2021
console.log();
21-
console.error(chalk.red(`Could not find the project ${chalk.blue(appHTMLFile)} file inside of the ` +
22-
`workspace config`));
22+
console.error(
23+
chalk.red(`Could not find the project ${chalk.blue(appHTMLFile)} file inside of the ` + `workspace config`)
24+
);
2325
return;
2426
}
25-
host.overwrite(appHTMLFile, bootPageHTML);
27+
const stat = fsStatSync(appHTMLFile);
28+
if (stat.mtimeMs === stat.ctimeMs) {
29+
host.overwrite(appHTMLFile, bootPageHTML);
30+
}
31+
2632
return host;
2733
};
2834
}

0 commit comments

Comments
 (0)