Skip to content
This repository was archived by the owner on Dec 8, 2022. It is now read-only.

Ignore public directory when generating components #187

Merged
merged 5 commits into from
Jun 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/sky-pages/sky-pages.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ module.exports = {
},
command: command,
componentsPattern: '**/*.component.ts',
componentsIgnorePattern: './public/',
includeRouteModule: true,
routesPattern: '**/index.html',
runtimeAlias: 'sky-pages-internal/runtime',
Expand Down
6 changes: 5 additions & 1 deletion lib/sky-pages-component-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ function generateComponents(skyAppConfig) {
// Prepend the alias and remove the file extension,
// since the file extension causes a TypeScript error.
return glob
.sync(path.join(skyAppConfig.runtime.srcPath, skyAppConfig.runtime.componentsPattern))
.sync(path.join(skyAppConfig.runtime.srcPath, skyAppConfig.runtime.componentsPattern), {
ignore: [
path.join(skyAppConfig.runtime.srcPath, skyAppConfig.runtime.componentsIgnorePattern)
]
})
.map(file => ({
importPath: skyAppConfig.runtime.spaPathAlias + '/' + file.replace(/\.[^\.]+$/, ''),
componentName: extractComponentName(file)
Expand Down
1 change: 1 addition & 0 deletions runtime/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface RuntimeConfig {
app: RuntimeConfigApp;
command?: string; // Dynamically added in "higher up" webpacks
componentsPattern: string;
componentsIgnorePattern: string;
handle404?: boolean; // Dynamically added in sky-pages-module-generator.js
includeRouteModule: boolean;
params: SkyAppRuntimeConfigParams;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// The contents of this file are stubbed in the unit test.
9 changes: 9 additions & 0 deletions test/sky-pages-component-generator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,13 @@ describe('SKY UX Builder component generator', () => {
);
});

it('should ignore components in the public directory', () => {
let config = runtimeUtils.getDefaultRuntime();
config.srcPath = './fixtures';
const components = generator.getComponents({
runtime: config
});
expect(components.names.length).toEqual(0);
});

});
1 change: 1 addition & 0 deletions utils/runtime-test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = {
},
command: '',
componentsPattern: '**/*.component.ts',
componentsIgnorePattern: './public/',
includeRouteModule: true,
routes: [],
routesPattern: '**/index.html',
Expand Down