fix(generator): fix generator

This commit is contained in:
thomas
2023-10-18 16:20:32 +02:00
parent c479fd0c82
commit 9aa77fbdb2

View File

@@ -7,7 +7,6 @@ import {
formatFiles, formatFiles,
generateFiles, generateFiles,
names, names,
readJsonFile,
Tree, Tree,
updateJson, updateJson,
} from '@nx/devkit'; } from '@nx/devkit';
@@ -48,11 +47,6 @@ export async function challengeGenerator(tree: Tree, options: Schema) {
const difficulty = options.challengeDifficulty; const difficulty = options.challengeDifficulty;
const challengeNumberPath = 'challenge-number.json';
const challangeNumberJson = readJsonFile(challengeNumberPath);
const challengeNumber = challangeNumberJson.total + 1;
const order = challangeNumberJson[difficulty] + 1;
await applicationGenerator(tree, { await applicationGenerator(tree, {
...options, ...options,
directory: `apps/${options.category}`, directory: `apps/${options.category}`,
@@ -69,6 +63,13 @@ export async function challengeGenerator(tree: Tree, options: Schema) {
skipTests: true, skipTests: true,
}); });
const challengeNumberPath = 'challenge-number.json';
const challangeNumberJson = JSON.parse(
tree.read(challengeNumberPath).toString()
);
const challengeNumber = challangeNumberJson.total + 1;
const order = challangeNumberJson[difficulty] + 1;
generateFiles(tree, join(__dirname, 'files', 'app'), appDirectory, { generateFiles(tree, join(__dirname, 'files', 'app'), appDirectory, {
tmpl: '', tmpl: '',
}); });