Skip to content

Commit

Permalink
fix(build): skip the current loop under specific circumstances
Browse files Browse the repository at this point in the history
  • Loading branch information
AnYiEE committed Feb 19, 2024
1 parent 131163b commit e161a8a
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions scripts/modules/utils/build-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,86 +456,96 @@ const findSourceFile = (): SourceFiles => {
switch (fileName) {
case 'definition.json':
targetGadget.definition = generateDefinition(gadgetName);
break;
continue;
case 'index.js': {
const {script} = targetGadget;
if (!script || !/^index\.[jt]sx?$/.test(script)) {
targetGadget.script = fileName;
continue;
}
break;
}
case 'index.jsx': {
const {script} = targetGadget;
if (!script || !/^index\.tsx?$/.test(script)) {
targetGadget.script = fileName;
continue;
}
break;
}
case 'index.ts': {
const {script} = targetGadget;
if (!script || script !== 'index.tsx') {
targetGadget.script = fileName;
continue;
}
break;
}
case 'index.tsx':
targetGadget.script = fileName;
break;
continue;
case `${gadgetName}.js`: {
const {script} = targetGadget;
if (!script) {
targetGadget.script = fileName;
continue;
}
break;
}
case `${gadgetName}.jsx`: {
const {script} = targetGadget;
if (!script || (!/\.tsx?$/.test(script) && script !== 'index.js')) {
targetGadget.script = fileName;
continue;
}
break;
}
case `${gadgetName}.ts`: {
const {script} = targetGadget;
if (!script || (!/^index\.[jt]sx?$/.test(script) && script !== `${gadgetName}.tsx`)) {
targetGadget.script = fileName;
continue;
}
break;
}
case `${gadgetName}.tsx`: {
const {script} = targetGadget;
if (!script || !/^index\.[jt]sx?$/.test(script)) {
targetGadget.script = fileName;
continue;
}
break;
}
case 'index.css': {
const {style} = targetGadget;
if (!style || style !== 'index.less') {
targetGadget.style = fileName;
continue;
}
break;
}
case 'index.less':
targetGadget.style = fileName;
break;
continue;
case `${gadgetName}.css`: {
const {style} = targetGadget;
if (!style) {
targetGadget.style = fileName;
continue;
}
break;
}
case `${gadgetName}.less`: {
const {style} = targetGadget;
if (!style || !/^index\.(?:css|less)/.test(style)) {
targetGadget.style = fileName;
continue;
}
break;
}
case 'LICENSE':
targetGadget.license = fileName;
break;
continue;
}

const fileExt: string = extname(fileName);
Expand Down

0 comments on commit e161a8a

Please sign in to comment.