mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 08:33:11 +00:00
refactor: remove pack
This commit is contained in:
@@ -18,10 +18,8 @@ import {Logger} from '@openstapps/logger';
|
||||
import {asyncPool} from 'async-pool-native/dist/async-pool';
|
||||
import {readFile, unlink, writeFile} from 'fs';
|
||||
import * as glob from 'glob';
|
||||
import {basename} from 'path';
|
||||
import {promisify} from 'util';
|
||||
import {PACK_IDENTIFIER} from './configuration';
|
||||
import {JavaScriptModule} from './pack/types';
|
||||
|
||||
/**
|
||||
* Instantiated logger
|
||||
@@ -129,33 +127,3 @@ export function getAllInternalDependecies(moduleContent: string): string[] {
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort modules by their dependencies
|
||||
*
|
||||
* @param modules Modules to sort
|
||||
*/
|
||||
export function topologicalSort(modules: JavaScriptModule[]): JavaScriptModule[] {
|
||||
const topoSort = require('toposort');
|
||||
|
||||
// vertices are modules, an edge from a to b means that b depends on a
|
||||
const edges: string[][] = [];
|
||||
const nodes: string[] = [];
|
||||
|
||||
// add all edges
|
||||
modules.forEach((module) => {
|
||||
module.dependencies.forEach((dependenciePath) => {
|
||||
// add edge from dependency to our module
|
||||
edges.push([basename(dependenciePath), module.name]);
|
||||
});
|
||||
|
||||
nodes.push(module.name);
|
||||
});
|
||||
|
||||
// sort graph and return as an array of sorted modules
|
||||
return topoSort.array(nodes, edges).map((moduleName: string) => {
|
||||
return modules.find((module) => {
|
||||
return module.name === moduleName;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user