Skip to content

Commit 921d996

Browse files
tomdaleaciccarello
authored andcommitted
Fix --plugin argument parsing (#682)
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.
1 parent efe70aa commit 921d996

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/lib/utils/options/declaration.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export interface DeclarationOption {
2626
scope?: ParameterScope;
2727
map?: {};
2828
mapError?: string;
29-
isArray?: boolean;
3029
defaultValue?: any;
3130
convert?: (param: OptionDeclaration, value?: any) => any;
3231
}

src/lib/utils/plugins.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ export class PluginHost extends AbstractComponent<Application> {
1111
@Option({
1212
name: 'plugin',
1313
help: 'Specify the npm plugins that should be loaded. Omit to load all installed plugins, set to \'none\' to load no plugins.',
14-
type: ParameterType.String,
15-
isArray: true
14+
type: ParameterType.Array
1615
})
1716
plugins: string[];
1817

src/test/plugin-host.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Application } from '..';
2+
import Assert = require('assert');
3+
4+
describe('PluginHost', function () {
5+
it('parses plugins correctly', function () {
6+
let app = new Application({
7+
plugin: 'typedoc-plugin-1,typedoc-plugin-2'
8+
});
9+
10+
Assert.deepEqual(app.plugins.plugins, [
11+
'typedoc-plugin-1',
12+
'typedoc-plugin-2'
13+
]);
14+
});
15+
});

0 commit comments

Comments
 (0)