Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions src/generators/generator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Clipboard } from "@napi-rs/clipboard";
import { camelCase, kebabCase, pascalCase } from "change-case";
import { outputFile, pathExists, remove } from "fs-extra/esm";
import Handlebars from "handlebars";
Expand Down Expand Up @@ -91,8 +90,12 @@ export function defineGenerator({

async function run(args: Args): Promise<void> {
const packagePath = args.cwd ?? env.GEMBER_CWD ?? processCwd();
const packageJson = await readPackageJson<EmberPackageJson>(packagePath);
const config = await resolveConfig(packagePath);

const [packageJson, config] = await Promise.all([
readPackageJson<EmberPackageJson>(packagePath),
resolveConfig(packagePath),
]);

const resolvedArgs = resolveArgs(
config,
generatorName,
Expand Down Expand Up @@ -169,14 +172,19 @@ export function defineGenerator({
signature: entityNameCases.pascal + "Signature",
},
package: packageJson,
testHelpersImportPath:
(await pathExists(join(packagePath, "tests", "helpers.js"))) ||
(await pathExists(join(packagePath, "tests", "helpers.ts")))
? `${packageJson.name}/tests/helpers`
: "ember-qunit",
testHelpersImportPath: (
await Promise.all([
pathExists(join(packagePath, "tests", "helpers.js")),
pathExists(join(packagePath, "tests", "helpers.ts")),
])
).some(Boolean)
? `${packageJson.name}/tests/helpers`
: "ember-qunit",
});

if (resolvedArgs.copy) {
const { Clipboard } = await import("@napi-rs/clipboard");

const clipboard = new Clipboard();

clipboard.setText(templateCompiled);
Expand Down