-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: default to current working directory when no plugins are provided #15
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,9 +7,10 @@ | |
|
||
import { IPlugin } from '@oclif/config'; | ||
import { flags, SfdxCommand } from '@salesforce/command'; | ||
import { Messages, SfdxError } from '@salesforce/core'; | ||
import { AnyJson, Dictionary, ensure, JsonMap } from '@salesforce/ts-types'; | ||
import { fs, Messages, SfdxError } from '@salesforce/core'; | ||
import { AnyJson, Dictionary, ensure, getString, JsonMap } from '@salesforce/ts-types'; | ||
import chalk = require('chalk'); | ||
import * as path from 'path'; | ||
import { Ditamap } from '../../ditamap/ditamap'; | ||
import { Docs } from '../../docs'; | ||
import { events, mergeDeep } from '../../utils'; | ||
|
@@ -34,15 +35,23 @@ export default class CommandReferenceGenerate extends SfdxCommand { | |
}), | ||
plugins: flags.array({ | ||
char: 'p', | ||
description: messages.getMessage('pluginFlagDescription'), | ||
required: true | ||
description: messages.getMessage('pluginFlagDescription') | ||
}), | ||
hidden: flags.boolean({ description: messages.getMessage('hiddenFlagDescription') }), | ||
erroronwarnings: flags.boolean({ description: messages.getMessage('erroronwarningFlagDescription') }) | ||
}; | ||
|
||
public async run(): Promise<AnyJson> { | ||
const plugins = this.flags.plugins | ||
let pluginNames: string[]; | ||
if (!this.flags.plugins) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add some error messaging? For example, I can do |
||
const pJsonPath = path.join(process.cwd(), 'package.json'); | ||
const packageJson = await fs.readJson(pJsonPath); | ||
pluginNames = [getString(packageJson, 'name')]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we log to the user what plugin we are going to generate reference for? |
||
} else { | ||
pluginNames = this.flags.plugins; | ||
} | ||
|
||
const plugins = pluginNames | ||
.map(plugin => plugin.trim()) | ||
.map(name => { | ||
let pluginName = name; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe.
- defaults to the plugin in the current working directory, if there is one
? See my note below.