- {label}:
+ {label + ' ' + mode}:
{
let foundGroups = [];
- walkModules(chunk.groups, module => {
- let weight = 0;
-
- /**
- * Splitting found modules/directories into groups:
- *
- * 1) Module with matched label (weight = 4)
- * 2) Directory with matched label (weight = 3)
- * 3) Module with matched path (weight = 2)
- * 4) Directory with matched path (weight = 1)
- */
- if (query.test(module.label)) {
- weight += 3;
- } else if (module.path && query.test(module.path)) {
- weight++;
- }
-
- if (!weight) return;
-
- if (!module.groups) {
- weight += 1;
+ if (this.searchMode === SEARCH_MODE.MODULES) {
+ walkModules(chunk.groups, module => {
+ let weight = 0;
+
+ /**
+ * Splitting found modules/directories into groups:
+ *
+ * 1) Module with matched label (weight = 4)
+ * 2) Directory with matched label (weight = 3)
+ * 3) Module with matched path (weight = 2)
+ * 4) Directory with matched path (weight = 1)
+ */
+ if (query.test(module.label)) {
+ weight += 3;
+ } else if (module.path && query.test(module.path)) {
+ weight++;
+ }
+
+ if (!weight) return;
+
+ if (!module.groups) {
+ weight += 1;
+ }
+
+ const foundModules = foundGroups[weight - 1] = foundGroups[weight - 1] || [];
+ foundModules.push(module);
+ });
+
+ const {activeSize} = this;
+
+ // Filtering out missing groups
+ foundGroups = foundGroups.filter(Boolean).reverse();
+ // Sorting each group by active size
+ foundGroups.forEach(modules =>
+ modules.sort((m1, m2) => m2[activeSize] - m1[activeSize])
+ );
+
+ return {
+ chunk,
+ modules: [].concat(...foundGroups)
+ };
+ } else {
+ let modules = [];
+ if (query.test(chunk.label)) {
+ modules = chunk.groups;
}
- const foundModules = foundGroups[weight - 1] = foundGroups[weight - 1] || [];
- foundModules.push(module);
- });
-
- const {activeSize} = this;
-
- // Filtering out missing groups
- foundGroups = foundGroups.filter(Boolean).reverse();
- // Sorting each group by active size
- foundGroups.forEach(modules =>
- modules.sort((m1, m2) => m2[activeSize] - m1[activeSize])
- );
-
- return {
- chunk,
- modules: [].concat(...foundGroups)
- };
+ return {
+ chunk,
+ modules
+ };
+ }
})
.filter(result => result.modules.length > 0)
.sort((c1, c2) => c1.modules.length - c2.modules.length);
diff --git a/gulpfile.js b/gulpfile.js
index 3a5a9e6e..b57056ae 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -2,8 +2,9 @@
const gulp = require('gulp');
-const NODE_SRC = './src/**/*.js';
+const NODE_SRC = ['./src/**/*.js'];
const NODE_DEST = './lib';
+const VIEWER_SRC = ['./client/**/*'];
const cli = require('commander')
.usage(' [options]')
@@ -32,7 +33,7 @@ class TaskError extends Error {
function watch() {
gulp
- .watch(NODE_SRC, gulp.series(cleanNodeScripts, compileNodeScripts))
+ .watch(NODE_SRC.concat(VIEWER_SRC), gulp.series(cleanNodeScripts, compileNodeScripts, compileViewerScripts))
// TODO: replace with `emitErrors: false` option after https://github.com/gulpjs/glob-watcher/pull/34 will be merged
.on('error', () => {});
}