Skip to content

Commit 428755f

Browse files
committed
init generator async fixes + add skipFormat option
1 parent a7b1472 commit 428755f

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed
Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import type { GeneratorCallback, Tree } from '@nx/devkit'
1+
import {
2+
runTasksInSerial,
3+
type GeneratorCallback,
4+
type Tree,
5+
formatFiles,
6+
} from '@nx/devkit'
27
import { addDependencies } from './lib'
38
import { addGitIgnore, addNxIgnore } from './lib/add-git-ignore-entry'
49
import type { InitGeneratorOptions } from './schema'
@@ -11,12 +16,17 @@ import type { InitGeneratorOptions } from './schema'
1116
*
1217
*/
1318
export async function initGenerator(
14-
tree: Tree,
15-
_options: InitGeneratorOptions,
19+
host: Tree,
20+
schema: InitGeneratorOptions,
1621
): Promise<GeneratorCallback> {
17-
addGitIgnore(tree)
18-
addNxIgnore(tree)
19-
return addDependencies(tree)
22+
const tasks: GeneratorCallback[] = []
23+
addGitIgnore(host)
24+
addNxIgnore(host)
25+
if (!schema.skipFormat) {
26+
await formatFiles(host)
27+
}
28+
tasks.push(addDependencies(host))
29+
return runTasksInSerial(...tasks)
2030
}
2131

2232
export default initGenerator
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
export type InitGeneratorOptions = unknown
1+
export type InitGeneratorOptions = {
2+
skipFormat?: boolean
3+
}

packages/nx-firebase/src/generators/init/schema.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
"title": "Init Firebase Plugin",
55
"description": "Init Firebase Plugin.",
66
"type": "object",
7-
"properties": {},
7+
"properties": {
8+
"skipFormat": {
9+
"description": "Skip formatting files.",
10+
"type": "boolean",
11+
"default": false
12+
}
13+
},
814
"required": []
915
}

0 commit comments

Comments
 (0)