R
R
ruHunterNic2021-08-07 18:51:34
Vue.js
ruHunterNic, 2021-08-07 18:51:34

How to crawl folders and check for the presence of a file?

When developing a new application, I came to the fact that the functionality will be divided into modules.
To register all routes from each module, I import them from the specified folder and add them to the existing array:

let baseRoutes = [];
import routeCore from '@/Modules/core/routes/index';
const routes = baseRoutes.concat(routeCore);

import routeModule1 from '@/Modules/module1/routes/index';
const routes = baseRoutes.concat(routeModule1);

import routeModule2 from '@/Modules/module2/routes/index';
const routes = baseRoutes.concat(routeModule2);

//.... и так далее

export default new VueRouter({
    base: '/app/',
    mode: 'history',
    linkActiveClass: 'has-active',
    linkExactActiveClass: 'active',
    routes: routes
});


All route files always lie strictly in the same path of their module folder and are named by the same file.
/Modules/core/routes/index
/Modules/module1/routes/index.js
/Modules/module2/routes/index.js


Tell me, how can I read the contents of the "Modules" folder, so that I can then bypass these folders and connect all the routes?

When working in Laravel Mix, I did it all through shelljs

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question