-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(build): process templates & customers entrypoints separately
- Loading branch information
1 parent
8e27b15
commit bee8bbc
Showing
2 changed files
with
29 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,25 @@ | ||
import * as fs from 'fs'; | ||
import * as glob from 'glob'; | ||
import * as path from 'path'; | ||
|
||
export function getTemplatesLiquidFiles(dir) { | ||
let results = []; | ||
const list = fs.readdirSync(dir); | ||
list.forEach(function (file) { | ||
const fileName = file; | ||
file = dir + '/' + file; | ||
const stat = fs.statSync(file); | ||
if (stat && stat.isDirectory()) { | ||
results = results.concat(getTemplatesLiquidFiles(file)); | ||
} else { | ||
const partOfName = fileName.split('.'); | ||
if (partOfName[1] == 'liquid') { | ||
results.push(fileName); | ||
} | ||
} | ||
export function getTemplateEntryPoints(sourceRoot) { | ||
const entrypoints = {}; | ||
|
||
const templatesEntries = glob.sync(`${sourceRoot}/theme/templates/**/*.ts`, { | ||
ignore: `${sourceRoot}/theme/templates/customers/**`, | ||
}); | ||
|
||
templatesEntries.forEach((filePath) => { | ||
const entryName = path.parse(filePath).name; | ||
entrypoints[`template.${entryName}`] = filePath; | ||
}); | ||
|
||
const templatesCustomersEntries = glob.sync( | ||
`${sourceRoot}/theme/templates/customers/**/*.ts` | ||
); | ||
templatesCustomersEntries.forEach((filePath) => { | ||
const entryName = path.parse(filePath).name; | ||
entrypoints[`template.customers.${entryName}`] = filePath; | ||
}); | ||
|
||
return results; | ||
return entrypoints; | ||
} |