Skip to content
This repository was archived by the owner on Jan 21, 2019. It is now read-only.

Commit 45cf4b8

Browse files
Find all the JavaScript files in common and patterns and add them to the manifest
1 parent 83d7ff2 commit 45cf4b8

File tree

4 files changed

+38
-8
lines changed

4 files changed

+38
-8
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ Patternbot adheres to [Semantic Versioning](http://semver.org/).
55

66
---
77

8+
## [Unreleased]
9+
10+
### Added
11+
12+
- Patternbot will now find all the JavaScript files within each pattern and add them to the manifest.
13+
14+
---
15+
816
## [3.0.5] — 2018-03-19
917

1018
### Fixed

app/renderer/lib/file-finder.js

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,25 @@ const findParseableFile = function (folderpath, filepath, patternLibKey) {
4444
});
4545
};
4646

47+
const findJavaScriptFiles = function (folderpath) {
48+
return new Promise((resolve, reject) => {
49+
glob(`${folderpath}/*.js`, (err, allJs) => {
50+
if (err) return resolve();
51+
52+
allJs.forEach((js) => {
53+
if (/patternbot(\.min)?\.js$/.test(js)) return;
54+
patternLibFiles.js.push({
55+
path: js,
56+
filename: path.basename(js),
57+
});
58+
});
59+
60+
patternLibFiles.js.sort();
61+
resolve();
62+
})
63+
});
64+
}
65+
4766
const findLogos = function (folderpath, imagesFolder) {
4867
return new Promise(function (resolve, reject) {
4968
let logoSizes = {
@@ -133,7 +152,7 @@ const findSubFiles = function (folderpath, subdir, patternLibKey) {
133152
};
134153

135154
const find = function (folderpath) {
136-
patternLibFiles = Object.assign({}, patternLibFilesDefaults);
155+
patternLibFiles = JSON.parse(JSON.stringify(patternLibFilesDefaults));
137156

138157
return new Promise(function (resolve, reject) {
139158
Promise.all([
@@ -143,14 +162,12 @@ const find = function (folderpath) {
143162
findParseableFile(folderpath, `${appPkg.config.commonFolder}/${appPkg.config.commonParsableFilenames.typografier}`, 'commonParsable.typografier'),
144163
findParseableFile(folderpath, `${appPkg.config.commonFolder}/${appPkg.config.commonParsableFilenames.theme}`, 'commonParsable.theme'),
145164
findParseableFile(folderpath, `${appPkg.config.imagesFolder}/${appPkg.config.imagesParsableFilenames.icons}`, 'imagesParsable.icons'),
165+
findLogos(folderpath, appPkg.config.imagesFolder),
166+
findSubDirectories(folderpath, appPkg.config.patternsFolder, 'patterns'),
167+
findSubFiles(folderpath, appPkg.config.pagesFolder, 'pages'),
168+
findJavaScriptFiles(`${folderpath}/${appPkg.config.commonFolder}`),
146169
]).then(function () {
147-
Promise.all([
148-
findLogos(folderpath, appPkg.config.imagesFolder),
149-
findSubDirectories(folderpath, appPkg.config.patternsFolder, 'patterns'),
150-
findSubFiles(folderpath, appPkg.config.pagesFolder, 'pages'),
151-
]).then(function () {
152-
resolve(patternLibFiles);
153-
});
170+
resolve(patternLibFiles);
154171
});
155172
});
156173
};

app/renderer/lib/pattern-lib-files.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ module.exports = {
1313
logos: [],
1414
patterns: [],
1515
pages: [],
16+
js: [],
1617
};

app/renderer/lib/pattern-parser.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const patternInfoDefaults = {
1919
path: '',
2020
html: {},
2121
md: {},
22+
css: [],
23+
js: [],
2224
};
2325

2426
const formatName = function (name) {
@@ -177,10 +179,12 @@ const getInfo = function (folderpath, limiter, readme, options = {}) {
177179
parseFilesWithExtension(theFolderPath, '.md', markdownFileParser, null, options),
178180
parseFilesWithExtension(theFolderPath, '.html', htmlFileParser, limiter, options),
179181
findFilesWithExtension(theFolderPath, '.css', limiter, options),
182+
findFilesWithExtension(theFolderPath, '.js', limiter, options),
180183
]).then(function (all) {
181184
patternInfo.md = all[0];
182185
patternInfo.html = all[1];
183186
patternInfo.css = all[2];
187+
patternInfo.js = all[3];
184188

185189
patternInfo.html.forEach((html, i) => {
186190
patternInfo.html[i].readme = setUpReadme(patternInfo.html[i], (patternInfo.md[0]) ? patternInfo.md[0] : null, html, readme, options);

0 commit comments

Comments
 (0)