Skip to content

Commit

Permalink
Breaking: Remove unsupported aliases (yarnpkg#3904)
Browse files Browse the repository at this point in the history
* Remove unsupported aliases

* Remove leftover tests and unused vars
  • Loading branch information
onurtemizkan authored and voxsim committed Jul 11, 2017
1 parent d9e86b6 commit df321cd
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 111 deletions.
32 changes: 0 additions & 32 deletions __tests__/cli/unsupported-aliases.js

This file was deleted.

18 changes: 0 additions & 18 deletions __tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,24 +222,6 @@ test.concurrent('should not output JSON activity/progress if given --no-progress
});
});

test.concurrent('should interpolate unsupported aliases', async () => {
await expectAnErrorMessage(execCommand('i', [], 'run-add', true), 'Did you mean `yarn install`?');
});

test.concurrent('should display correct documentation link for unsupported aliases', async () => {
await expectAnInfoMessageAfterError(
execCommand('i', [], 'run-add', true),
'Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.',
);
});

test.concurrent('should show help and ignore unsupported aliases', async () => {
const stdout = await execCommand('i', ['--help'], 'run-help');
expect(stdout[stdout.length - 1]).toEqual(
'Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.',
);
});

test.concurrent('should run help of run command if --help is before --', async () => {
const stdout = await execCommand('run', ['custom-script', '--help', '--'], 'run-custom-script-with-arguments');
expect(stdout[0]).toEqual('Usage: yarn [command] [flags]');
Expand Down
7 changes: 1 addition & 6 deletions src/cli/commands/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import * as constants from '../../constants.js';
import type {Reporter} from '../../reporters/index.js';
import type Config from '../../config.js';
import {sortAlpha, hyphenate} from '../../util/misc.js';
import unsupportedAliases from '../unsupported-aliases.js';
import aliases from '../aliases';
const chalk = require('chalk');

Expand Down Expand Up @@ -43,11 +42,7 @@ export function run(config: Config, reporter: Reporter, commander: Object, args:
const getDocsLink = name => `${constants.YARN_DOCS}${name || ''}`;
console.log(' Commands:\n');
for (const name of Object.keys(commands).sort(sortAlpha)) {
if (
commands[name].useless ||
unsupportedAliases[name] ||
Object.keys(aliases).map(key => aliases[key]).indexOf(name) > -1
) {
if (commands[name].useless || Object.keys(aliases).map(key => aliases[key]).indexOf(name) > -1) {
continue;
}
if (aliases[name]) {
Expand Down
16 changes: 0 additions & 16 deletions src/cli/commands/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
/* @flow */
import {ConsoleReporter, JSONReporter} from '../../reporters/index.js';
import * as constants from '../../constants.js';
import {MessageError} from '../../errors.js';
import Config from '../../config.js';

const chalk = require('chalk');

Expand Down Expand Up @@ -101,17 +98,4 @@ for (const key in aliases) {
commands[key].getDocsInfo = getDocsInfo(key);
}

import unsupportedAliases from '../unsupported-aliases.js';

for (const key in unsupportedAliases) {
commands[key] = {
run(config: Config, reporter: ConsoleReporter | JSONReporter): Promise<void> {
throw new MessageError(`Did you mean \`yarn ${unsupportedAliases[key]}\`?`);
},
setFlags: () => {},
hasWrapper: () => true,
getDocsInfo: getDocsInfo(unsupportedAliases[key]),
};
}

export default commands;
39 changes: 0 additions & 39 deletions src/cli/unsupported-aliases.js

This file was deleted.

0 comments on commit df321cd

Please sign in to comment.