Skip to content

Support sort option in lerna.json#596

Merged
evocateur merged 1 commit intolerna:masterfrom
gigabo:sort-config
Feb 16, 2017
Merged

Support sort option in lerna.json#596
evocateur merged 1 commit intolerna:masterfrom
gigabo:sort-config

Conversation

@gigabo
Copy link
Copy Markdown
Contributor

@gigabo gigabo commented Feb 10, 2017

Can be configured at the top level or per-command.

Example:

{
  ...
  "commands": {
    "run": {
      "sort": false
    }
  }
}

Can be configured at the top level or per-command.

Example:

```js
{
  ...
  "commands": {
    "run": {
      "sort": false
    }
  }
}
```
Comment thread src/Command.js
const {sort} = this.getOptions();

// If the option isn't present then the default is to sort.
this.toposort = sort == null || sort;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since this.toposort is never referenced until the initialize method of subclasses, it seems like we could wait to determine this in runPreparations() or something. My concern (perhaps unfounded?) is that calling getOptions() in the constructor might "miss" the otherCommandConfigs override? Do I just suck at class inheritance?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@evocateur Good thought! The constructor name is actually pulled from the object bound to this rather than the class where the method is defined, so it should work as intended in this case.

Here's a small script to demonstrate:

class Foo {
  constructor() {
    console.log(this.constructor.name);
  }
}

class Bar extends Foo {}

new Bar;

This prints Bar rather than Foo, since that's what is instantiated.

Thanks for thinking through this so carefully!

@evocateur evocateur merged commit 3021dc3 into lerna:master Feb 16, 2017
@lock
Copy link
Copy Markdown

lock Bot commented Dec 27, 2018

This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock Bot locked as resolved and limited conversation to collaborators Dec 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants