Skip to content

Commit

Permalink
feat(web): process all files under webSourcePath nested
Browse files Browse the repository at this point in the history
  • Loading branch information
saadjutt01 committed Jul 2, 2021
1 parent 646d030 commit 70941c6
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 124 deletions.
22 changes: 16 additions & 6 deletions src/commands/build/build.ts
Expand Up @@ -211,7 +211,7 @@ async function getFolderContent(serverType: ServerType) {
await asyncForEach(buildSubFolders, async (subFolder) => {
const { content, contentJSON } = await getContentFor(
path.join(buildDestinationFolder, subFolder),
subFolder,
path.join(buildDestinationFolder, subFolder),
serverType
)

Expand All @@ -234,21 +234,23 @@ async function getDependencies(filePaths: string[]): Promise<string> {
}

async function getContentFor(
rootDirectory: string,
folderPath: string,
folderName: string,
serverType: ServerType,
testPath: string | undefined = undefined
) {
const folderName = path.basename(folderPath)
if (!testPath && folderName === 'tests') {
testPath = ''
}

const isRootDir = folderPath === rootDirectory
let content = `\n%let path=${
folderName === 'services'
isRootDir
? ''
: testPath !== undefined
? testPath
: folderName
: folderPath.replace(rootDirectory, '').substr(1)
};\n`

const contentJSON: any = {
Expand Down Expand Up @@ -294,8 +296,8 @@ async function getContentFor(
await asyncForEach(subFolders, async (subFolder) => {
const { content: childContent, contentJSON: childContentJSON } =
await getContentFor(
rootDirectory,
path.join(folderPath, subFolder),
subFolder,
serverType,
testPath !== undefined
? testPath === ''
Expand Down Expand Up @@ -367,7 +369,15 @@ async function getWebFileContent(filePath: string, type: string) {
let lines,
encoded = false

const typesToEncode: string[] = ['ICO', 'PNG', 'JPG', 'JPEG', 'MP3']
const typesToEncode: string[] = [
'ICO',
'PNG',
'JPG',
'JPEG',
'MP3',
'OGG',
'WAV'
]

if (typesToEncode.includes(type)) {
encoded = true
Expand Down

0 comments on commit 70941c6

Please sign in to comment.