Simplify cli options stack (#11994)
This commit is contained in:
1 parent
e90882a016
commit
cf4bf1adc0
2 files changed
+9
-13
No files matched your search
+8
-13
@@ -1,5 +1,7 @@
|
||||
"use strict";
|
||||
const pick = require("lodash/pick");
|
||||
const {
|
||||
utils: { getLast },
|
||||
} = require("./prettier-internal.js");
|
||||
const getContextOptions = require("./options/get-context-options.js");
|
||||
const {
|
||||
parseArgv,
|
||||
@@ -46,21 +48,14 @@ class Context {
|
||||
* @param {string[]=} pluginSearchDirs
|
||||
*/
|
||||
pushContextPlugins(plugins, pluginSearchDirs) {
|
||||
this.stack.push(
|
||||
pick(this, [
|
||||
"supportOptions",
|
||||
"detailedOptions",
|
||||
"detailedOptionMap",
|
||||
"apiDefaultOptions",
|
||||
"languages",
|
||||
])
|
||||
);
|
||||
|
||||
Object.assign(this, getContextOptions(plugins, pluginSearchDirs));
|
||||
const options = getContextOptions(plugins, pluginSearchDirs);
|
||||
this.stack.push(options);
|
||||
Object.assign(this, options);
|
||||
}
|
||||
|
||||
popContextPlugins() {
|
||||
Object.assign(this, this.stack.pop());
|
||||
this.stack.pop();
|
||||
Object.assign(this, getLast(this.stack));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,6 +74,7 @@ module.exports = {
|
||||
optionsNormalizer: require("./main/options-normalizer.js"),
|
||||
utils: {
|
||||
arrayify: require("./utils/arrayify.js"),
|
||||
getLast: require("./utils/get-last.js"),
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
Reference in new issue
Block a user