Skip to content

refactor: rename "blacklist" -> "blocklist" #193

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

Merged
merged 1 commit into from
Dec 1, 2021
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
4 changes: 2 additions & 2 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const EXIT_CODES = {
SUCCESS: 0,
};

export const CMD_BLACKLIST = [
export const CMD_BLOCKLIST = [
'cd',
'pushd',
'popd',
Expand All @@ -17,7 +17,7 @@ export const CMD_BLACKLIST = [
'ShellString',
];

export const OPTION_BLACKLIST = [
export const OPTION_BLOCKLIST = [
'globOptions', // we don't have good control over globbing in the shell
'execPath', // we don't currently support exec
'bufLength', // we don't use buffers in shx
Expand Down
6 changes: 3 additions & 3 deletions src/help.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import shell from 'shelljs';
import { CMD_BLACKLIST, OPTION_BLACKLIST } from './config';
import { CMD_BLOCKLIST, OPTION_BLOCKLIST } from './config';

// Global options defined directly in shx.
const locallyDefinedOptions = ['version'];

const shxOptions = Object.keys(shell.config)
.filter(key => typeof shell.config[key] !== 'function')
.filter(key => OPTION_BLACKLIST.indexOf(key) === -1)
.filter(key => OPTION_BLOCKLIST.indexOf(key) === -1)
.concat(locallyDefinedOptions)
.map(key => ` * --${key}`);

export default () => {
// Note: compute this at runtime so that we have all plugins loaded.
const commandList = Object.keys(shell)
.filter(cmd => typeof shell[cmd] === 'function')
.filter(cmd => CMD_BLACKLIST.indexOf(cmd) === -1)
.filter(cmd => CMD_BLOCKLIST.indexOf(cmd) === -1)
.map(cmd => ` * ${cmd}`);

return `
Expand Down
4 changes: 2 additions & 2 deletions src/shx.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import minimist from 'minimist';
import path from 'path';
import fs from 'fs';
import help from './help';
import { CMD_BLACKLIST, EXIT_CODES, CONFIG_FILE } from './config';
import { CMD_BLOCKLIST, EXIT_CODES, CONFIG_FILE } from './config';
import { printCmdRet } from './printCmdRet';

shell.help = help;
Expand Down Expand Up @@ -81,7 +81,7 @@ export function shx(argv) {
console.error(`Error: Invalid ShellJS command: ${fnName}.`);
console.error(help());
return EXIT_CODES.SHX_ERROR;
} else if (CMD_BLACKLIST.indexOf(fnName) > -1) {
} else if (CMD_BLOCKLIST.indexOf(fnName) > -1) {
console.error(`Warning: shx ${fnName} is not supported`);
console.error('Please run `shx help` for a list of commands.');
return EXIT_CODES.SHX_ERROR;
Expand Down
2 changes: 1 addition & 1 deletion test/specs/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('cli', () => {
output.code.should.equal(EXIT_CODES.SHX_ERROR);
});

it('fails for blacklisted commands', () => {
it('fails for blocked commands', () => {
const output = cli('cd', 'src');
output.stdout.should.equal('');
output.stderr.should.match(/Warning: shx cd is not supported\n/);
Expand Down