Skip to content

Commit

Permalink
Remove packages in non-empty namespace (#1992) (#2036)
Browse files Browse the repository at this point in the history
* Remove packages in non-empty namespace (#1992)

* Add a test for removing a single scoped package (#1992)

* Minimize fixtures for scoped-package test (#1992)

* Fix remove command test (#1992)

* Inline subfilepath (#1992)
  • Loading branch information
DenisGorbachev authored and wyze committed Nov 29, 2016
1 parent 2a0afc7 commit d8b72f3
Show file tree
Hide file tree
Showing 20 changed files with 63 additions and 288 deletions.
23 changes: 20 additions & 3 deletions __tests__/commands/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ test.concurrent('removes multiple installed packages', (): Promise<void> => {
});


test.concurrent('removes scoped packages', (): Promise<void> => {
return runRemove(['@scoped/package'], {}, 'scoped-package', async (config): Promise<void> => {
assert(!await fs.exists(path.join(config.cwd, 'node_modules/@scoped')));
test.concurrent('removes the whole scope when all scoped packages are removed', (): Promise<void> => {
return runRemove(['@dengorbachev/foo', '@dengorbachev/bar'], {}, 'scoped-package', async (config): Promise<void> => {
assert(!await fs.exists(path.join(config.cwd, 'node_modules/@dengorbachev')));

assert.deepEqual(
JSON.parse(await fs.readFile(path.join(config.cwd, 'package.json'))).dependencies,
Expand All @@ -93,6 +93,23 @@ test.concurrent('removes scoped packages', (): Promise<void> => {
});
});

test.concurrent('removes a single scoped package', (): Promise<void> => {
return runRemove(['@dengorbachev/foo'], {}, 'scoped-package', async (config): Promise<void> => {
assert(!await fs.exists(path.join(config.cwd, 'node_modules/@dengorbachev/foo')));

assert.deepEqual(
JSON.parse(await fs.readFile(path.join(config.cwd, 'package.json'))).dependencies,
{
'@dengorbachev/bar': '^1.0.0',
},
);

const lockFileContent = await fs.readFile(path.join(config.cwd, 'yarn.lock'));
const lockFileLines = explodeLockfile(lockFileContent);
assert.equal(lockFileLines.length, 3);
});
});

test.concurrent('removes subdependencies', (): Promise<void> => {
// A@1 -> B@1
// C@1
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

This file was deleted.

Empty file.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

3 changes: 2 additions & 1 deletion __tests__/fixtures/remove/scoped-package/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"dependencies": {
"@scoped/package": "^1.0.1"
"@dengorbachev/bar": "^1.0.0",
"@dengorbachev/foo": "^1.0.0"
}
}
11 changes: 8 additions & 3 deletions __tests__/fixtures/remove/scoped-package/yarn.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@scoped/package":
version "1.0.1"
resolved package-1.0.1.tgz#d25a1f99e2506dcb27d6704b83dca8a312e4edcc


"@dengorbachev/bar@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@dengorbachev/bar/-/bar-1.0.0.tgz#f01d868a938353e52703a6751ebf07e92016060d"

"@dengorbachev/foo@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@dengorbachev/foo/-/foo-1.0.0.tgz#67a8228a6cc54d7062b1de314bad734882302205"
Loading

0 comments on commit d8b72f3

Please sign in to comment.