Skip to content

Commit

Permalink
fix: watch src/app.ts for tmp file regeneration, and do uniq
Browse files Browse the repository at this point in the history
  • Loading branch information
sorrycc committed Mar 20, 2020
1 parent 3acfc80 commit df8bf7c
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions packages/preset-built-in/src/plugins/commands/generateFiles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IApi } from '@umijs/types';
import { chokidar, lodash } from '@umijs/utils';
import { chokidar, lodash, winPath } from '@umijs/utils';
import { join } from 'path';

export default async ({ api, watch }: { api: IApi; watch?: boolean }) => {
Expand All @@ -21,9 +21,20 @@ export default async ({ api, watch }: { api: IApi; watch?: boolean }) => {
const watcherPaths = await api.applyPlugins({
key: 'addTmpGenerateWatcherPaths',
type: api.ApplyPluginsType.add,
initialValue: [paths.absPagesPath!, join(paths.absSrcPath!, 'layouts')],
initialValue: [
paths.absPagesPath!,
join(paths.absSrcPath!, 'layouts'),
join(paths.absSrcPath!, 'app.tsx'),
join(paths.absSrcPath!, 'app.ts'),
join(paths.absSrcPath!, 'app.jsx'),
join(paths.absSrcPath!, 'app.js'),
],
});
watcherPaths.forEach(createWatcher);
lodash
.uniq<string>(watcherPaths.map((p: string) => winPath(p)))
.forEach((p: string) => {
createWatcher(p);
});
// process.on('SIGINT', () => {
// console.log('SIGINT');
// unwatch();
Expand Down

0 comments on commit df8bf7c

Please sign in to comment.