Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: main schematic rule usage #73

Open
neodmy opened this issue Oct 30, 2023 · 0 comments
Open

BUG: main schematic rule usage #73

neodmy opened this issue Oct 30, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@neodmy
Copy link
Contributor

neodmy commented Oct 30, 2023

Description

I've noticed we might not be implementing the main schematic rule properly. TypeScript throws a type error. Fortunately, I believe it doesn't have an impact on functionality, and the schematics work.

Expected Behavior

The return should yield a Rule

export function main(options: Options): Rule {
	return (_tree: Tree, context: SchematicContext): Rule => {
		context.logger.info('Creating .nvmrc file and updating package.json...');

		const templateSource = apply(url('./files'), [
			template({...options}),
			move(normalize(options.directory)),
		]);

		return chain([
			mergeWith(templateSource, MergeStrategy.Overwrite),
			updatePackageJson(options),
		]);
	};
}

Actual Behavior

export function main(options: Options): Rule {
	return (tree: Tree, context: SchematicContext): Rule => {
		context.logger.info('Creating .nvmrc file and updating package.json...');

		const templateSource = apply(url('./files'), [
			template({...options}),
			move(normalize(options.directory)),
		]);

		return chain([
			mergeWith(templateSource, MergeStrategy.Overwrite),
			updatePackageJson(options),
		])(tree, context); // no need for calling the second function
	};
}

Possible Fix

Return the result of the schematics function used (which in turn returns a Rule; e.g. mergeWith, chain, etc)

@neodmy neodmy added the bug Something isn't working label Oct 30, 2023
@neodmy neodmy mentioned this issue Oct 30, 2023
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant