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

Type mistmatch between return types of ValidateHelper and validate #272

Closed
JamesLMilner opened this issue Nov 30, 2018 · 0 comments
Closed
Assignees

Comments

@JamesLMilner
Copy link
Contributor

JamesLMilner commented Nov 30, 2018

Bug

There is currently a mismatch between the a commands .validate method and the ValidateHelper. .validate returns type of boolean but the ValidateHelper returns a Promise, meaning you can't use the helper in a command. Making .validate async would fix this issue.

Code

	validate(helper: Helper) {
		let schema;
		try {
			schema = JSON.parse(readFileSync(path.join(__dirname, 'schema.json')).toString());
		} catch (error) {
			return Promise.reject(Error('The dojorc schema for cli-build-app could not be read: ' + error));
		}
		return helper.validation.validate({
			commandGroup: command.group as string,
			commandName: command.name,
			commandSchema: schema,
			commandConfig: helper.configuration.get(),
			silentSuccess: true
		});
	}

Expected behavior:

You should be able to use the provided ValidateHelper in the .validate function.

Actual behavior:

ValidateHelper is async which stops it from being useable.

screenshot_20181130_113710

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant