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

Combine deno.removeAll into deno.remove #1596

Merged
merged 1 commit into from
Jan 28, 2019
Merged

Conversation

loujiayu
Copy link
Contributor

Closes #1584

@CLAassistant
Copy link

CLAassistant commented Jan 27, 2019

CLA assistant check
All committers have signed the CLA.

js/remove.ts Outdated
*/
export async function removeAll(path: string): Promise<void> {
await dispatch.sendAsync(...req(path, true));
export async function remove(path: string, recursive = false): Promise<void> {
Copy link
Contributor

@axetroy axetroy Jan 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we pass an options object { recursive: boolean } instead of recursive = false ?
This makes it easier to extend the interface
At the same time, single boolean will make people confused

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@axetroy Got it.

Copy link
Contributor

@axetroy axetroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should declare an options interface and exports it.
instead of a single boolean argument

eg.

interface removeOption {
  recursive?: boolean;
}

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

README.md Outdated

```
curl -L https://deno.land/x/install/install.py | python
curl -L https://deno.land/x/install/install.sh | bash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an unrelated change. Please remove

export function removeSync(path: string): void {
dispatch.sendSync(...req(path, false));
export interface RemoveOption {
recursive?: boolean;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a huge fan of these Options interfaces with just a single member...
But I think it makes sense to mirror the interface in deno.mkdir(d, { recursive: true })

cc @piscisaureus here is another example of a function which will never have more than one option.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope! An option could be whether to remove readonly files also (not a thing on linux, but kinda important on windows and a thing on os x also)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A good argument in favor of using options objects, even when they have a single member, is simply how confusing boolean traps are.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@kevinkassimo kevinkassimo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
I rebased and squashed it - thanks @loujiayu !

@ry ry merged commit f7c0f49 into denoland:master Jan 28, 2019
@loujiayu loujiayu deleted the combine_remove branch January 29, 2019 02:17
@capicuadev
Copy link

It would be better to call it removeOptions (plural) like the rest, even if you only have one option?

Should we unify the use of an option object for the other functions? For example mkdir(path: string, options?: MkdirOptions) instead of mkdir(path: string, mode?: number).

On the other hand, it should be changed to run(args: string[], options: RunOptions) instead of run(opt: RunOptions)? Because the arguments are not really an option.

And finally, should a new issue be opened for this?

(Sorry for my English)

This pull request was closed.
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

Successfully merging this pull request may close these issues.

8 participants