|
1 | | -import { Clipboard } from "@napi-rs/clipboard"; |
2 | 1 | import { camelCase, kebabCase, pascalCase } from "change-case"; |
3 | 2 | import { outputFile, pathExists, remove } from "fs-extra/esm"; |
4 | 3 | import Handlebars from "handlebars"; |
@@ -91,8 +90,12 @@ export function defineGenerator({ |
91 | 90 |
|
92 | 91 | async function run(args: Args): Promise<void> { |
93 | 92 | const packagePath = args.cwd ?? env.GEMBER_CWD ?? processCwd(); |
94 | | - const packageJson = await readPackageJson<EmberPackageJson>(packagePath); |
95 | | - const config = await resolveConfig(packagePath); |
| 93 | + |
| 94 | + const [packageJson, config] = await Promise.all([ |
| 95 | + readPackageJson<EmberPackageJson>(packagePath), |
| 96 | + resolveConfig(packagePath), |
| 97 | + ]); |
| 98 | + |
96 | 99 | const resolvedArgs = resolveArgs( |
97 | 100 | config, |
98 | 101 | generatorName, |
@@ -169,14 +172,19 @@ export function defineGenerator({ |
169 | 172 | signature: entityNameCases.pascal + "Signature", |
170 | 173 | }, |
171 | 174 | package: packageJson, |
172 | | - testHelpersImportPath: |
173 | | - (await pathExists(join(packagePath, "tests", "helpers.js"))) || |
174 | | - (await pathExists(join(packagePath, "tests", "helpers.ts"))) |
175 | | - ? `${packageJson.name}/tests/helpers` |
176 | | - : "ember-qunit", |
| 175 | + testHelpersImportPath: ( |
| 176 | + await Promise.all([ |
| 177 | + pathExists(join(packagePath, "tests", "helpers.js")), |
| 178 | + pathExists(join(packagePath, "tests", "helpers.ts")), |
| 179 | + ]) |
| 180 | + ).some(Boolean) |
| 181 | + ? `${packageJson.name}/tests/helpers` |
| 182 | + : "ember-qunit", |
177 | 183 | }); |
178 | 184 |
|
179 | 185 | if (resolvedArgs.copy) { |
| 186 | + const { Clipboard } = await import("@napi-rs/clipboard"); |
| 187 | + |
180 | 188 | const clipboard = new Clipboard(); |
181 | 189 |
|
182 | 190 | clipboard.setText(templateCompiled); |
|
0 commit comments