(entryPoints, platform, options, callback = noop)
| 56 | |
| 57 | exports.create = function create(resolve: ResolveFn, load: LoadFn): GraphFn { |
| 58 | function Graph(entryPoints, platform, options, callback = noop) { |
| 59 | const { |
| 60 | log = (console: any), |
| 61 | optimize = false, |
| 62 | skip, |
| 63 | } = options || NO_OPTIONS; |
| 64 | |
| 65 | if (typeof platform !== 'string') { |
| 66 | log.error('`Graph`, called without a platform'); |
| 67 | callback(Error('The target platform has to be passed')); |
| 68 | return; |
| 69 | } |
| 70 | |
| 71 | const loadQueue: LoadQueue = queue(seq( |
| 72 | ({id, parent}, cb) => resolve(id, parent, platform, options || NO_OPTIONS, cb), |
| 73 | memoize((file, cb) => load(file, {log, optimize}, cb)), |
| 74 | ), Number.MAX_SAFE_INTEGER); |
| 75 | |
| 76 | const {collect, loadModule} = createGraphHelpers(loadQueue, skip); |
| 77 | |
| 78 | loadQueue.drain = () => { |
| 79 | loadQueue.kill(); |
| 80 | callback(null, collect()); |
| 81 | }; |
| 82 | loadQueue.error = error => { |
| 83 | loadQueue.error = noop; |
| 84 | loadQueue.kill(); |
| 85 | callback(error); |
| 86 | }; |
| 87 | |
| 88 | let i = 0; |
| 89 | for (const entryPoint of entryPoints) { |
| 90 | loadModule(entryPoint, null, i++); |
| 91 | } |
| 92 | |
| 93 | if (i === 0) { |
| 94 | log.error('`Graph` called without any entry points'); |
| 95 | loadQueue.kill(); |
| 96 | callback(Error('At least one entry point has to be passed.')); |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | return Graph; |
| 101 | }; |
nothing calls this directly
no test coverage detected
searching dependent graphs…