Skip to content

Commit

Permalink
fix: isVertexShader
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuki Shimada committed Dec 24, 2024
1 parent 46aec4c commit 6c81c3a
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,28 @@ if(isNode()) {
}

function isVertexShader(path: string) {
const ext = fileExtension(path);
if (ext == 'vs' || ext == 'vert') {
if (includeWordsInFileExtension(path, ['vs', 'vert'])) {
return true;
} else {
return false;
}
}

function fileExtension(path: string) {
function includeWordsInFileExtension(path: string, words: string[]) {
const splitted = path.split('.');
const ext = splitted[splitted.length - 1];

return ext;
if (splitted.length >= 2) {
for (let i = 0; i < words.length; i++) {
if (splitted[splitted.length - 1].includes(words[i])) {
return true;
}
if (splitted.length >= 3) {
if (splitted[splitted.length - 2].includes(words[i])) {
return true;
}
}
}
}
return false;
}

/**
Expand Down

0 comments on commit 6c81c3a

Please sign in to comment.