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

Properly sort added dependency during init #59

Merged
merged 1 commit into from
Nov 18, 2016

Conversation

evocateur
Copy link
Contributor

Unfortunately, there are no tests for the InitCommand. In any case, here's a demonstration of what this patch fixes:

Before

$ cat package.json
{
  "name": "test",
  "devDependencies" {
    "eslint": "^3.9.1"
  }
}
$ asini init --loglevel=silent
$ cat package.json
{
  "name": "test",
  "devDependencies" {
    "eslint": "^3.9.1",
    "asini": "1.2.0"
  }
}

After

$ cat package.json
{
  "name": "test",
  "devDependencies" {
    "eslint": "^3.9.1"
  }
}
$ asini init --loglevel=silent
$ cat package.json
{
  "name": "test",
  "devDependencies" {
    "asini": "1.2.0",
    "eslint": "^3.9.1"
  }
}

It seems to do fine with sorting when asini already exists, but fails to properly replace the referenced object when asini is being added to the dependencies.

I also removed the irrelevant lerna stuff.

}

objectAssignSorted(targetDependencies, {
lerna: this.lernaVersion
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, man... what is this I don't even... :squint:

I must have botched a port of a Lerna patch somehow.

Thanks for cleaning this up while you were in here @evocateur!

@gigabo
Copy link
Contributor

gigabo commented Nov 18, 2016

This is great. It more closely matches what npm itself does when adding dependencies.

Thanks @evocateur!

@gigabo gigabo merged commit b3485a5 into asini:master Nov 18, 2016
@evocateur evocateur deleted the fix-init-sort branch November 18, 2016 18:58
@gigabo gigabo changed the title init: properly sort added dependency instead of mutating by reference Properly sort added dependency during init Nov 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants