-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSfExtension.js
42 lines (37 loc) · 1.28 KB
/
SfExtension.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const Generator = require('yeoman-generator');
/**
* @typedef {import('@salesforce/command').SfdxCommand} SfdxCommand
*/
/**
* @typedef {object} SfExtensionConfig
* @param {object} config oclif/sfdx runtime configs
* @param {SfdxCommand} command the sfdx command to which this extension is currently attached
* @param {string} lifecycle 'before' or 'after' which indicates when this extension is running in relation to the sfdxCommand
*/
class SfExtension extends Generator{
/**
* constructor
* @param {Array<string>} args yeoman args
* @param {SfExtensionConfig} config
*/
constructor(yoArgs, sfContext){
super(yoArgs, sfContext);
// default desintationRoot to process.cwd()
this.destinationRoot(process.cwd());
// set sfContext
let { config, Command, lifecycle, yargs } = sfContext;
this.sfContext = {
config,
Command,
lifecycle,
yargs
};
}
set forceOverwrite(forceOverwrite){
if(!this.env.conflicter) throw new Error('Must set forceOverwrite during Yeoman running context');
if(forceOverwrite && typeof forceOverwrite === 'boolean'){
this.env.conflicter.force = forceOverwrite;
}
}
}
module.exports = SfExtension;