Skip to content

Commit

Permalink
Fix --plugin argument parsing (#682)
Browse files Browse the repository at this point in the history
Currently, the `--plugin` argument simply doesn't work because it tries to treat the provided string as an array. For example, if I pass `--plugin foo`, it will try to load three npm packages named `f`, `o`, and `o` respectively.

This commit changes the option declaration to use the `ParameterType.Array` type, which parses a comma-separated string into an array. It also removes the otherwise-unused `isArray` property from the `DeclarationOptions` interface.
  • Loading branch information
tomdale authored and aciccarello committed Feb 1, 2018
1 parent efe70aa commit 921d996
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/lib/utils/options/declaration.ts
Expand Up @@ -26,7 +26,6 @@ export interface DeclarationOption {
scope?: ParameterScope;
map?: {};
mapError?: string;
isArray?: boolean;
defaultValue?: any;
convert?: (param: OptionDeclaration, value?: any) => any;
}
Expand Down
3 changes: 1 addition & 2 deletions src/lib/utils/plugins.ts
Expand Up @@ -11,8 +11,7 @@ export class PluginHost extends AbstractComponent<Application> {
@Option({
name: 'plugin',
help: 'Specify the npm plugins that should be loaded. Omit to load all installed plugins, set to \'none\' to load no plugins.',
type: ParameterType.String,
isArray: true
type: ParameterType.Array
})
plugins: string[];

Expand Down
15 changes: 15 additions & 0 deletions src/test/plugin-host.ts
@@ -0,0 +1,15 @@
import { Application } from '..';
import Assert = require('assert');

describe('PluginHost', function () {
it('parses plugins correctly', function () {
let app = new Application({
plugin: 'typedoc-plugin-1,typedoc-plugin-2'
});

Assert.deepEqual(app.plugins.plugins, [
'typedoc-plugin-1',
'typedoc-plugin-2'
]);
});
});

0 comments on commit 921d996

Please sign in to comment.