UNPKG

1.02 kBJavaScriptView Raw
1"use strict";
2var __importDefault = (this && this.__importDefault) || function (mod) {
3 return (mod && mod.__esModule) ? mod : { "default": mod };
4};
5Object.defineProperty(exports, "__esModule", { value: true });
6exports.autoDetectEntries = void 0;
7const globby_1 = __importDefault(require("globby"));
8const path_1 = require("path");
9async function autoDetectEntries(options) {
10 const attempts = {
11 bundle: await globby_1.default(path_1.resolve(options.srcFolder, 'bundle.(js|ts)')),
12 application: await globby_1.default(path_1.resolve(options.srcFolder, 'js/(application|app).(js|ts|jsx|tsx)'))
13 };
14 const entries = {};
15 if (attempts.bundle.length) {
16 entries.bundle = attempts.bundle[0];
17 }
18 else if (attempts.application.length) {
19 entries['js/app'] = attempts.application[0];
20 }
21 else {
22 throw new Error('Unable to autodetect the main entry file. Please specify entries manually.');
23 }
24 return entries;
25}
26exports.autoDetectEntries = autoDetectEntries;