index.js 1022 Bytes
Newer Older
1
/*
Johannes Edmeier committed
2
 * Copyright 2014-2018 the original author or authors.
3 4 5 6 7
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
Johannes Edmeier committed
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9 10 11 12 13 14 15 16
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

17

Johannes Edmeier committed
18
const components = [];
19

Johannes Edmeier committed
20
const context = require.context('.', false, /^(?:(?!.*\.spec\.(js|vue)$).)*\.(js|vue)$/);
Johannes Edmeier committed
21 22 23
context.keys().forEach(function (key) {
  const name = /^(.\/)+(.*)\.(vue|js)$/.exec(key)[2];
  components.push({name, component: context(key).default})
24
});
Johannes Edmeier committed
25 26 27 28 29 30

export default {
  install(Vue) {
    components.forEach(component => Vue.component(component.name, component.component));
  }
}