执行过npm install命令的vue-element-admin源码
康凯
2022-05-20 aa4c235a8ca67ea8b731f90c951a465e92c0a865
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"use strict";
 
var _jestWatcher = require("jest-watcher");
 
var _jestRegexUtil = require("jest-regex-util");
 
var _prompt = _interopRequireDefault(require("./prompt"));
 
var _utils = require("../lib/utils");
 
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 
class FileNamePlugin {
  constructor({
    stdin,
    stdout,
    config = {}
  }) {
    this._stdin = stdin;
    this._stdout = stdout;
    this._prompt = new _jestWatcher.Prompt();
    this._projects = [];
    this._usageInfo = {
      key: config.key || 'p',
      prompt: config.prompt || 'filter by a filename regex pattern'
    };
  }
 
  apply(jestHooks) {
    jestHooks.onFileChange(({
      projects
    }) => {
      this._projects = projects;
    });
  }
 
  onKey(key) {
    this._prompt.put(key);
  }
 
  run(globalConfig, updateConfigAndRun) {
    const p = new _prompt.default(this._stdout, this._prompt);
    p.updateSearchSources(this._projects);
    return new Promise((res, rej) => {
      p.run(value => {
        updateConfigAndRun({
          mode: 'watch',
          testPathPattern: (0, _utils.removeTrimmingDots)(value).split('/').map(_jestRegexUtil.escapeStrForRegex).join('/')
        });
        res();
      }, rej);
    });
  }
 
  getUsageInfo() {
    return this._usageInfo;
  }
 
}
 
module.exports = FileNamePlugin;