Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

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